From 0158b3af794adf713f94e799dfe4031de379b071 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 12 May 2017 23:01:51 -0700 Subject: [PATCH] blank page victory --- pitfall/pitfall/kit/demo.pdf | 51 ++++++++++++++++++++++---- pitfall/pitfall/kit/document.rkt | 18 ++++----- pitfall/pitfall/kit/temp.pdf | 0 pitfall/pitfall/kit/zzz.pdf | 63 -------------------------------- 4 files changed, 52 insertions(+), 80 deletions(-) delete mode 100644 pitfall/pitfall/kit/temp.pdf delete mode 100644 pitfall/pitfall/kit/zzz.pdf diff --git a/pitfall/pitfall/kit/demo.pdf b/pitfall/pitfall/kit/demo.pdf index ccb55820..2b72418f 100644 --- a/pitfall/pitfall/kit/demo.pdf +++ b/pitfall/pitfall/kit/demo.pdf @@ -1,20 +1,57 @@ %PDF-1.3 %ÿÿÿÿ 5 0 obj +<< +/Parent 1 0 R +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +>> +endobj 4 0 obj +<< +/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] +>> +endobj 3 0 obj +<< +/Length 18 +>> +stream +1 0 0 -1 0 792 cm + +endstream +endobj 6 0 obj +<< +/Producer (PitfallKit) +/CreationDate 0 +/Creator (PitfallKit) +>> +endobj 2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj 1 0 obj +<< +/Kids [5 0 R] +/Count 1 +/Type /Pages +>> +endobj xref 0 7 0000000000 65535 f -0000057005 00000 n -0000057005 00000 n -0000057005 00000 n -0000057005 00000 n -0000057005 00000 n -0000057005 00000 n +0000000385 00000 n +0000000336 00000 n +0000000186 00000 n +0000000119 00000 n +0000000015 00000 n +0000000254 00000 n trailer << /Info 6 0 R @@ -22,5 +59,5 @@ trailer /Size 7 >> startxref -63 +442 %%EOF diff --git a/pitfall/pitfall/kit/document.rkt b/pitfall/pitfall/kit/document.rkt index e71c4a3d..3ee97160 100644 --- a/pitfall/pitfall/kit/document.rkt +++ b/pitfall/pitfall/kit/document.rkt @@ -56,9 +56,9 @@ ;; Initialize the metadata (field [(@info info) (mhash - 'Producer "PDFKit" - 'Creator "PDFKit" - 'CreationDate (seconds->date (current-seconds)))]) + 'Producer "PitfallKit" + 'Creator "PitfallKit" + 'CreationDate #;(seconds->date (current-seconds)) 0)]) ; debug val (when (hash-ref @options 'info #f) (for ([(key val) (in-hash (hash-ref @options 'info))]) @@ -133,7 +133,7 @@ (public [@ref ref]) (define (@ref [data (make-hasheq)]) (define ref (make-object PDFReference this (add1 (length @_offsets)) data)) - (push-end @_offsets (* 1000 (add1 (length @_offsets)))) ; placeholder for this object's offset once it is finalized + (push-end @_offsets #f) ; placeholder for this object's offset once it is finalized (++ @_waiting) ref) @@ -155,12 +155,10 @@ this) (define/public (_refEnd ref) - (report* @_offsets (· ref id) (· ref offset)) (set! @_offsets (for/list ([(offset idx) (in-indexed @_offsets)]) - (if (= (sub1 (· ref id)) idx) + (if (= (· ref id) (add1 idx)) (· ref offset) offset))) - (report* @_offsets) (-- @_waiting) (if (and (zero? @_waiting) @_ended) (@_finalize) @@ -201,7 +199,7 @@ (@_write "0000000000 65535 f ") (for ([offset (in-list @_offsets)]) (@_write (string-append - (~r (or offset #xdead) #;debug #:min-width 10 #:pad-string "0") + (~r offset #:min-width 10 #:pad-string "0") " 00000 n "))) ;; trailer (@_write "trailer") @@ -229,7 +227,7 @@ (require rackunit racket/file) (define ob (open-output-bytes)) (send doc pipe ob) - (send doc pipe (open-output-file "zzz.pdf" #:exists 'replace)) + #;(send doc pipe (open-output-file "demo.pdf" #:exists 'replace)) (check-equal? (send doc end) 'done) #;(display (get-output-bytes ob)) - #;(check-equal? (get-output-bytes ob) (file->bytes "demo.pdf"))) \ No newline at end of file + (check-equal? (get-output-bytes ob) (file->bytes "demo.pdf"))) \ No newline at end of file diff --git a/pitfall/pitfall/kit/temp.pdf b/pitfall/pitfall/kit/temp.pdf deleted file mode 100644 index e69de29b..00000000 diff --git a/pitfall/pitfall/kit/zzz.pdf b/pitfall/pitfall/kit/zzz.pdf deleted file mode 100644 index e2708d61..00000000 --- a/pitfall/pitfall/kit/zzz.pdf +++ /dev/null @@ -1,63 +0,0 @@ -%PDF-1.3 -%ÿÿÿÿ -5 0 obj -<< -/Parent 1 0 R -/Resources 4 0 R -/Contents 3 0 R -/MediaBox [0 0 612 792] -/Type /Page ->> -endobj -4 0 obj -<< -/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] ->> -endobj -3 0 obj -<< -/Length 18 ->> -stream -1 0 0 -1 0 792 cm - -endstream -endobj -6 0 obj -<< -/Producer (PDFKit) -/CreationDate (D:20170512224816Z) -/Creator (PDFKit) ->> -endobj -2 0 obj -<< -/Pages 1 0 R -/Type /Catalog ->> -endobj -1 0 obj -<< -/Kids [5 0 R] -/Count 1 -/Type /Pages ->> -endobj -xref -0 7 -0000000000 65535 f -0000000395 00000 n -0000000346 00000 n -0000000186 00000 n -0000000119 00000 n -0000000015 00000 n -0000000254 00000 n -trailer -<< -/Info 6 0 R -/Root 2 0 R -/Size 7 ->> -startxref -452 -%%EOF