start-doc and end-doc

main
Matthew Butterick 6 years ago
parent dedbd5be3e
commit 00e0470114

@ -60,10 +60,6 @@
(for ([(key val) (in-hash (hash-ref @options 'info (hasheq)))]) (for ([(key val) (in-hash (hash-ref @options 'info (hasheq)))])
(hash-set! @info key val)) (hash-set! @info key val))
;; write the header now, before any other subroutine starts up
(write-bytes-out (format "%PDF-~a" (current-pdf-version)))
(write-bytes-out "%ÿÿÿÿ")
(define/public (store-ref ref) (define/public (store-ref ref)
(set! @refs (cons ref @refs))) (set! @refs (cons ref @refs)))
@ -81,7 +77,11 @@
(transform 1 0 0 -1 0 (get-field height (page))) (transform 1 0 0 -1 0 (get-field height (page)))
this) this)
(define/public (end) (define/public (start-doc)
(write-bytes-out (format "%PDF-~a" (current-pdf-version)))
(write-bytes-out "%ÿÿÿÿ"))
(define/public (end-doc)
(for ([page (in-list @pages)]) (for ([page (in-list @pages)])
(send page end)) (send page end))

@ -38,8 +38,9 @@
(with-output-to-file ps (with-output-to-file ps
(λ () (λ ()
(define doc (make-object PDFDocument (hash 'compress compress?))) (define doc (make-object PDFDocument (hash 'compress compress?)))
(send doc start-doc)
(proc doc) (proc doc)
(send doc end)) (send doc end-doc))
#:exists 'replace)) #:exists 'replace))
(when test? (when test?
(check-headers-equal? ps (this->control ps)) (check-headers-equal? ps (this->control ps))

Loading…
Cancel
Save