main
Matthew Butterick 7 years ago
parent 6bf2ee32be
commit f83c68043e

@ -1,5 +1,6 @@
#lang br #lang racket/base
(require racket/draw) (require racket/class racket/draw br/list racket/list racket/format racket/port)
(require sugar/debug)
(provide PDFDocument) (provide PDFDocument)
(require "reference.rkt" "struct.rkt" "object.rkt") (require "reference.rkt" "struct.rkt" "object.rkt")
@ -50,8 +51,8 @@
;; Initialize the metadata ;; Initialize the metadata
(field [info (hasheq (field [info (hasheq
'Producer 'PitfallKit' 'Producer "PitfallKit"
'Creator 'PitfallKit' 'Creator "PitfallKit"
'CreationDate (seconds->date (current-seconds)))]) 'CreationDate (seconds->date (current-seconds)))])
(when (hash-ref options 'info #f) (when (hash-ref options 'info #f)
@ -165,7 +166,7 @@
(send _root end) (send _root end)
(send (hash-ref (get-field data _root) 'Pages) end) (send (hash-ref (get-field data _root) 'Pages) end)
(if (or (zero? _waiting) #t) ; debug (if (or (zero? _waiting) 'debug)
(_finalize) (_finalize)
(set! _ended #t)) (set! _ended #t))
@ -179,7 +180,7 @@
(_write "0000000000 65535 f ") (_write "0000000000 65535 f ")
(for ([offset (in-list _offsets)]) (for ([offset (in-list _offsets)])
(_write (string-append (_write (string-append
(~r (or offset 42) #;debug #:min-width 10 #:pad-string "0") (~r (or offset (random 17)) #;debug #:min-width 10 #:pad-string "0")
" 00000 n "))) " 00000 n ")))
;; trailer ;; trailer
(_write "trailer") (_write "trailer")
@ -207,4 +208,4 @@
(module+ test (module+ test
(require rackunit) (require rackunit)
(send doc pipe (open-output-file "testrkt0.pdf" #:exists 'replace)) (send doc pipe (open-output-file "testrkt0.pdf" #:exists 'replace))
(check-equal? (send doc end) 'done)) (check-equal? (send doc end) 'done))

Loading…
Cancel
Save