diff --git a/pitfall/ptest/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt similarity index 91% rename from pitfall/ptest/check-pdf.rkt rename to pitfall/pitfall/check-pdf.rkt index 35d4a2c0..ed2a057b 100644 --- a/pitfall/ptest/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -60,7 +60,9 @@ (unless (even? (length items)) (raise items)) (define dic (sort ; put hash into order so it's comparable - (for/list ([kv (in-slice 2 items)]) + (for/list ([kv (in-slice 2 items)] + ;; suppress these keys so we can compare pdfkit & pitfall output + #:unless (member (car kv) (list #"/Producer" #"/Creator" #"/CreationDate"))) (apply cons kv)) bytesdict ps1) (pdf->dict ps2))) -(for ([p (in-directory)] - #:when (path-has-extension? p #"pdf")) - (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) - (pdf->dict p))) +#;(module+ main + (for ([p (in-directory)] + #:when (path-has-extension? p #"pdf")) + (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) + (pdf->dict p)))) diff --git a/pitfall/pitfall/fonts.rkt b/pitfall/pitfall/fonts.rkt index 91cd0428..11e9e84d 100644 --- a/pitfall/pitfall/fonts.rkt +++ b/pitfall/pitfall/fonts.rkt @@ -65,7 +65,7 @@ (set-field! _font this val))] ;; load the font [else - (println (format "Load font: ~a" src)) + #;(println (format "Load font: ~a" src)) (define id (format "F~a" (increment-field! _fontCount this))) (set-field! _font this (PDFFont-open this src family id)) diff --git a/pitfall/pitfall/pdftest.rkt b/pitfall/pitfall/pdftest.rkt index 41b940e1..ef9e677a 100644 --- a/pitfall/pitfall/pdftest.rkt +++ b/pitfall/pitfall/pdftest.rkt @@ -1,5 +1,5 @@ #lang racket/base -(require "racket.rkt") +(require "racket.rkt" "check-pdf.rkt") (provide (all-from-out "racket.rkt")) (provide check-copy-equal? check-pdfkit? make-doc) @@ -11,7 +11,7 @@ (define (this->control this) (path-add-extension this #"" #" copy.")) (define (this->pdfkit-control this) - (string->path (string-replace (path->string this) "rkt." "."))) + (string->path (string-replace ((if (string? this) values path->string) this) "rkt." "."))) (module+ test (require rackunit) @@ -27,18 +27,12 @@ (define-syntax-rule (check-pdfkit? this) (check-equal? (file-size this) (file-size (this->pdfkit-control this)))) -(define (make-doc ps compress? [proc (λ (doc) doc)] #:test [test? #t] #:pdfkit [pdfkit? #t]) +(define (make-doc ps [compress? #false] [proc (λ (doc) doc)] #:test [test? #t] #:pdfkit [pdfkit? #t]) (define doc (make-object PDFDocument (hash 'compress compress?))) (send doc pipe (open-output-file ps #:exists 'replace)) (proc doc) (send doc end) (when test? - (check-copy-equal? ps) + (check-pdfs-equal? ps (this->control ps)) (when pdfkit? - (check-pdfkit? ps)))) - - -(module reader syntax/module-reader - #:language 'pitfall/pdftest - #:read read - #:read-syntax read-syntax) \ No newline at end of file + (check-pdfs-equal? ps (this->pdfkit-control ps))))) diff --git a/pitfall/ptest/minion-test.pdf b/pitfall/ptest/minion-test.pdf index 59c3cc72..b3d30f52 100644 Binary files a/pitfall/ptest/minion-test.pdf and b/pitfall/ptest/minion-test.pdf differ diff --git a/pitfall/ptest/out.bin b/pitfall/ptest/out.bin index cedbe02c..befa81da 100644 Binary files a/pitfall/ptest/out.bin and b/pitfall/ptest/out.bin differ diff --git a/pitfall/ptest/test.pdf b/pitfall/ptest/test.pdf index b07d48fd..d47fdea6 100644 Binary files a/pitfall/ptest/test.pdf and b/pitfall/ptest/test.pdf differ diff --git a/pitfall/ptest/test0.pdf b/pitfall/ptest/test0.pdf index 11e86b83..eaec4037 100644 --- a/pitfall/ptest/test0.pdf +++ b/pitfall/ptest/test0.pdf @@ -27,7 +27,7 @@ endobj << /Producer (PDFKit) /Creator (PDFKit) -/CreationDate (D:20170519204252Z) +/CreationDate (D:20181120220342Z) >> endobj 2 0 obj diff --git a/pitfall/ptest/test0.rkt b/pitfall/ptest/test0.rkt index 623903d4..1a66f08d 100644 --- a/pitfall/ptest/test0.rkt +++ b/pitfall/ptest/test0.rkt @@ -1,8 +1,8 @@ #lang racket/base (require pitfall/pdftest) -(define-runtime-path this "test0rkt.pdf") -(make-doc this #f) +(define-runtime-path pdf "test0rkt.pdf") +(make-doc pdf) -(define-runtime-path that "test0crkt.pdf") -(make-doc that #t) +(define-runtime-path pdfc "test0crkt.pdf") +(make-doc pdfc 'compress) diff --git a/pitfall/ptest/test0c.pdf b/pitfall/ptest/test0c.pdf index 836343dd..2be69d7c 100644 Binary files a/pitfall/ptest/test0c.pdf and b/pitfall/ptest/test0c.pdf differ diff --git a/pitfall/ptest/test0crkt.pdf b/pitfall/ptest/test0crkt.pdf new file mode 100644 index 00000000..bc92c9d6 Binary files /dev/null and b/pitfall/ptest/test0crkt.pdf differ diff --git a/pitfall/ptest/test0rkt.pdf b/pitfall/ptest/test0rkt.pdf new file mode 100644 index 00000000..d405f41b --- /dev/null +++ b/pitfall/ptest/test0rkt.pdf @@ -0,0 +1,63 @@ +%PDF-1.3 +% +5 0 obj +<< +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +/Parent 1 0 R +>> +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 +<< +/CreationDate (D:19700101000000Z) +/Producer (PITKIT) +/Creator (PITKIT) +>> +endobj +2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +1 0 obj +<< +/Kids [5 0 R] +/Type /Pages +/Count 1 +>> +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 +<< +/Size 7 +/Root 2 0 R +/Info 6 0 R +>> +startxref +452 +%%EOF diff --git a/pitfall/ptest/test1.pdf b/pitfall/ptest/test1.pdf index 9e4c9159..4503f51f 100644 --- a/pitfall/ptest/test1.pdf +++ b/pitfall/ptest/test1.pdf @@ -54,7 +54,7 @@ endobj << /Producer (PDFKit) /Creator (PDFKit) -/CreationDate (D:20170519210746Z) +/CreationDate (D:20181120215403Z) >> endobj 2 0 obj diff --git a/pitfall/ptest/test1c.pdf b/pitfall/ptest/test1c.pdf index ffcab08e..4111b493 100644 --- a/pitfall/ptest/test1c.pdf +++ b/pitfall/ptest/test1c.pdf @@ -27,7 +27,7 @@ endobj << /Producer (PDFKit) /Creator (PDFKit) -/CreationDate (D:20170519210746Z) +/CreationDate (D:20181120215403Z) >> endobj 2 0 obj diff --git a/pitfall/ptest/test1crkt.pdf b/pitfall/ptest/test1crkt.pdf new file mode 100644 index 00000000..b48b07e7 --- /dev/null +++ b/pitfall/ptest/test1crkt.pdf @@ -0,0 +1,76 @@ +%PDF-1.3 +% +6 0 obj +<< +/ca 1 +/Type /ExtGState +>> +endobj +5 0 obj +<< +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +/Parent 1 0 R +>> +endobj +4 0 obj +<< +/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] +/ExtGState << +/Gs1 6 0 R +>> +>> +endobj +3 0 obj +<< +/Filter /FlateDecode +/Length 151 +>> +stream +x]] +0@Z + +@-@&C2 #Įp3}It`MNWnDpj$NPss&d%^.j*sS${i<>+|Yz71<ަ|caaE= +endstream +endobj +7 0 obj +<< +/CreationDate (D:19700101000000Z) +/Producer (PITKIT) +/Creator (PITKIT) +>> +endobj +2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +1 0 obj +<< +/Kids [5 0 R] +/Type /Pages +/Count 1 +>> +endobj +xref +0 8 +0000000000 65535 f +0000000622 00000 n +0000000573 00000 n +0000000258 00000 n +0000000163 00000 n +0000000059 00000 n +0000000015 00000 n +0000000481 00000 n +trailer +<< +/Size 8 +/Root 2 0 R +/Info 7 0 R +>> +startxref +679 +%%EOF diff --git a/pitfall/ptest/test1rkt.pdf b/pitfall/ptest/test1rkt.pdf new file mode 100644 index 00000000..a41bec0e --- /dev/null +++ b/pitfall/ptest/test1rkt.pdf @@ -0,0 +1,91 @@ +%PDF-1.3 +% +6 0 obj +<< +/ca 1 +/Type /ExtGState +>> +endobj +5 0 obj +<< +/Resources 4 0 R +/Contents 3 0 R +/MediaBox [0 0 612 792] +/Type /Page +/Parent 1 0 R +>> +endobj +4 0 obj +<< +/ProcSet [/PDF /Text /ImageB /ImageC /ImageI] +/ExtGState << +/Gs1 6 0 R +>> +>> +endobj +3 0 obj +<< +/Length 294 +>> +stream +1 0 0 -1 0 792 cm +q +100 150 m +100 250 l +200 250 l +/DeviceRGB cs +1 0.2 0 scn +/Gs1 gs +f +230 200 m +230 172.385763 252.385763 150 280 150 c +307.614237 150 330 172.385763 330 200 c +330 227.614237 307.614237 250 280 250 c +252.385763 250 230 227.614237 230 200 c +h +/DeviceRGB cs +0.4 0 1 scn +/Gs1 gs +f + +endstream +endobj +7 0 obj +<< +/CreationDate (D:19700101000000Z) +/Producer (PITKIT) +/Creator (PITKIT) +>> +endobj +2 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +1 0 obj +<< +/Kids [5 0 R] +/Type /Pages +/Count 1 +>> +endobj +xref +0 8 +0000000000 65535 f +0000000744 00000 n +0000000695 00000 n +0000000258 00000 n +0000000163 00000 n +0000000059 00000 n +0000000015 00000 n +0000000603 00000 n +trailer +<< +/Size 8 +/Root 2 0 R +/Info 7 0 R +>> +startxref +801 +%%EOF