don't use end method for writing

main
Matthew Butterick 6 years ago
parent 8902a4721f
commit a70d20e6cd

@ -24,21 +24,20 @@
(init-field [(@options options) (mhasheq)])
(field [@pages null]
[@refs null]
[ref-gen (generator () (let loop ([refid 1])
[@ref-gen (generator () (let loop ([refid 1])
(yield refid)
(loop (add1 refid))))]
[(@root _root) (ref (mhasheq 'Type "Catalog"
'Pages (ref (mhasheq 'Type "Pages"
'Count 0
'Kids empty))))] ; top object
[@root (ref (mhasheq 'Type "Catalog"
'Pages (ref (mhasheq 'Type "Pages"
'Count 0
'Kids empty))))] ; top object
[(@x x) 0]
[(@y y) 0]
[(@info info) (mhasheq
'Producer "PITFALL"
'Creator "PITFALL"
'CreationDate (seconds->date (if (test-mode)
0
(current-seconds)) #f))]) ; Initialize the metadata
[@info (mhasheq 'Producer "PITFALL"
'Creator "PITFALL"
'CreationDate (seconds->date (if (test-mode)
0
(current-seconds)) #f))]) ; Initialize the metadata
;; Initialize mixins
(send this initColor)
@ -56,8 +55,11 @@
(define/public (page) (first @pages))
;; for use by page.rkt rather than invading our fields
(define/public (page-parent) (hash-ref (get-field payload @root) 'Pages))
(define/public (ref [payload (mhasheq)])
(define refid (ref-gen))
(define refid (@ref-gen))
(define new-ref (make-object PDFReference this refid payload))
(set! @refs (cons new-ref @refs))
new-ref)

@ -92,7 +92,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(when isCFF
(hash-set! (· fontFile payload) 'Subtype "CIDFontType0C"))
(send fontFile end (get-output-bytes (encode-to-port (· this subset))))
(send* fontFile [write (get-output-bytes (encode-to-port (· this subset)))] [end])
(define familyClass (let ([val (if (has-table? (· this font) 'OS/2)
(· (get-OS/2-table (· this font)) sFamilyClass)
@ -199,7 +199,8 @@ end
HERE
)
(send cmap end (format unicode-cmap-str (toHex (sub1 (length entries))) (string-join entries " ")))
(send* cmap [write (format unicode-cmap-str (toHex (sub1 (length entries))) (string-join entries " "))]
[end])
cmap)

@ -71,7 +71,8 @@
(hash-set! (· this obj payload) 'Decode '(1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0)))
(port-position (· this data) 0)
(send (· this obj) end (· this data))))
(send* (· this obj) [write (· this data)]
[end])))
(module+ test
(require rackunit)

@ -36,7 +36,7 @@
[dictionary
(send document ref
(mhash 'Type "Page"
'Parent (· document _root payload Pages)
'Parent (send document page-parent)
'MediaBox (list 0 0 width height)
'Contents content
'Resources resources))])

@ -54,7 +54,7 @@
[(hash-has-key? (· this image) 'palette)
;; embed the color palette in the PDF as an object stream
(define palette-ref (· this document ref))
(send palette-ref end (· this image palette))
(send* palette-ref [write (· this image palette)] [end])
;; build the color space array for the image
(hash-set! (· this object payload) 'Colorspace
@ -90,11 +90,11 @@
'Filter "FlateDecode"
'ColorSpace "DeviceGray"
'Decode '(0 1))))
(send sMask end (· this alphaChannel))
(send* sMask [write (· this alphaChannel)] [end])
(hash-set! (· this obj payload) 'SMask sMask))
;; embed the actual image data
(send (· this obj) end (· this imgData)))
(send* (· this obj) [write (· this imgData)] [end]))
(define (split-alpha-channel this)

Loading…
Cancel
Save