diff --git a/pitfall/pitfall/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt index eddb2d70..293c24a9 100644 --- a/pitfall/pitfall/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -79,7 +79,7 @@ (list (cons 'stream (if font? #"0" stream)))) ;; compressed length may vary, so just set to #"0" #"/Length" (λ (val) (cond - [(or font? compressed?) #"0"] + [(or font? compressed?) (bytes-length stream)] [else val])))] [else dic])] [else @@ -90,7 +90,7 @@ ["[-]?\\d*\\.\\d+"] ; real ["[-]?\\d+\\.?"] ; integer ["\\(.*?\\)"] ; parenstring - ["/[A-Z]{6}(\\+\\w+)" => cadr] ; font keystring. prefix is random, so ignore + ["/[A-Z]{6}(\\+\\S+)" => cadr] ; font keystring. prefix is random, so ignore ["/\\S+"] ; keystring [else eof])])) @@ -118,13 +118,15 @@ (cons idx (parse-pdf-bytes (peek-bytes (- end start) start))))) < #:key car)) -(define (dict-compare d1 d2) +(define (dict-compare arg1 arg2) + (define d1 (if (dict? arg1) arg1 (pdf->dict arg1))) + (define d2 (if (dict? arg2) arg2 (pdf->dict arg2))) (and (dict? d1) (dict? d2) (= (length d1) (length d2)) (for/and ([(k1 v1) (in-dict d1)] [(k2 v2) (in-dict d2)]) (unless (equal? k1 k2) - (error (format "keys unequal: ~a ~a" k1 k2))) + (error (format "keys unequal in ~a and ~a: ~a ≠ ~a" arg1 arg2 k1 k2))) (unless (equal? v1 v2) (define val1 (if (and (bytes? v1) (> (bytes-length v1) 200)) (subbytes v1 0 200) @@ -132,13 +134,13 @@ (define val2 (if (and (bytes? v2) (> (bytes-length v2) 200)) (subbytes v2 0 200) v2)) - (error (format "values unequal: ~a ~a" val1 val2))) + (error (format "values unequal in ~a and ~a: ~a ≠ ~a" arg1 arg2 val1 val2))) (when (dict? v1) (dict-compare v1 v2)) #true))) (define-simple-check (check-pdfs-equal? ps1 ps2) - (dict-compare (pdf->dict ps1) (pdf->dict ps2))) + (dict-compare ps1 ps2)) #;(module+ main (for ([p (in-directory)] diff --git a/pitfall/ptest/out.bin b/pitfall/ptest/out.bin index 0be09337..2870701f 100644 Binary files a/pitfall/ptest/out.bin and b/pitfall/ptest/out.bin differ diff --git a/pitfall/ptest/test14.coffee b/pitfall/ptest/test14.coffee index 4c1c5525..fc1a3623 100644 --- a/pitfall/ptest/test14.coffee +++ b/pitfall/ptest/test14.coffee @@ -18,3 +18,6 @@ doc = new PDFDocument({compress: no}) doc.pipe(fs.createWriteStream('test14.pdf')) make doc +doc = new PDFDocument({compress: yes}) +doc.pipe(fs.createWriteStream('test14c.pdf')) +make doc diff --git a/pitfall/ptest/test14.pdf b/pitfall/ptest/test14.pdf index 009f0b67..94f9737b 100644 Binary files a/pitfall/ptest/test14.pdf and b/pitfall/ptest/test14.pdf differ diff --git a/pitfall/ptest/test14.rkt b/pitfall/ptest/test14.rkt index 64190a01..3ce01cd1 100644 --- a/pitfall/ptest/test14.rkt +++ b/pitfall/ptest/test14.rkt @@ -16,7 +16,7 @@ ;; test against non-subsetted font version (define-runtime-path this "test14rkt.pdf") -(make-doc this #f proc ) +(make-doc this #f proc) (define-runtime-path that "test14crkt.pdf") -(make-doc that #t proc #:pdfkit #f) +(make-doc that #t proc) diff --git a/pitfall/ptest/test14c.pdf b/pitfall/ptest/test14c.pdf new file mode 100644 index 00000000..90effd25 Binary files /dev/null and b/pitfall/ptest/test14c.pdf differ diff --git a/pitfall/ptest/test14crkt copy.pdf b/pitfall/ptest/test14crkt copy.pdf index 19a862dc..e2f4edb0 100644 Binary files a/pitfall/ptest/test14crkt copy.pdf and b/pitfall/ptest/test14crkt copy.pdf differ diff --git a/pitfall/ptest/test14crkt.pdf b/pitfall/ptest/test14crkt.pdf new file mode 100644 index 00000000..e2f4edb0 Binary files /dev/null and b/pitfall/ptest/test14crkt.pdf differ diff --git a/pitfall/ptest/test14rkt copy.pdf b/pitfall/ptest/test14rkt copy.pdf index a2e57e9f..53591945 100644 Binary files a/pitfall/ptest/test14rkt copy.pdf and b/pitfall/ptest/test14rkt copy.pdf differ diff --git a/pitfall/ptest/test14rkt copy 2.pdf b/pitfall/ptest/test14rkt.pdf similarity index 77% rename from pitfall/ptest/test14rkt copy 2.pdf rename to pitfall/ptest/test14rkt.pdf index 45b1154d..53591945 100644 Binary files a/pitfall/ptest/test14rkt copy 2.pdf and b/pitfall/ptest/test14rkt.pdf differ diff --git a/pitfall/ptest/test15.coffee b/pitfall/ptest/test15.coffee index 53cbb1f9..b82c9171 100644 --- a/pitfall/ptest/test15.coffee +++ b/pitfall/ptest/test15.coffee @@ -18,3 +18,7 @@ doc = new PDFDocument({compress: no}) doc.pipe(fs.createWriteStream('test15.pdf')) make doc +doc = new PDFDocument({compress: yes}) +doc.pipe(fs.createWriteStream('test15c.pdf')) +make doc + diff --git a/pitfall/ptest/test15.pdf b/pitfall/ptest/test15.pdf index 5ba4007e..42f1203c 100644 Binary files a/pitfall/ptest/test15.pdf and b/pitfall/ptest/test15.pdf differ diff --git a/pitfall/ptest/test15.rkt b/pitfall/ptest/test15.rkt index 86559c59..1f5505d8 100644 --- a/pitfall/ptest/test15.rkt +++ b/pitfall/ptest/test15.rkt @@ -20,4 +20,4 @@ (make-doc this #f proc) (define-runtime-path that "test15crkt.pdf") -(make-doc that #t proc #:pdfkit #f) \ No newline at end of file +(make-doc that #t proc) \ No newline at end of file diff --git a/pitfall/ptest/test15c.pdf b/pitfall/ptest/test15c.pdf new file mode 100644 index 00000000..0839508c Binary files /dev/null and b/pitfall/ptest/test15c.pdf differ diff --git a/pitfall/ptest/test15crkt.pdf b/pitfall/ptest/test15crkt.pdf new file mode 100644 index 00000000..00c2c718 Binary files /dev/null and b/pitfall/ptest/test15crkt.pdf differ diff --git a/pitfall/ptest/test15rkt.pdf b/pitfall/ptest/test15rkt.pdf new file mode 100644 index 00000000..efe98733 Binary files /dev/null and b/pitfall/ptest/test15rkt.pdf differ diff --git a/pitfall/ptest/test16.coffee b/pitfall/ptest/test16.coffee index 6a3e814f..39192acd 100644 --- a/pitfall/ptest/test16.coffee +++ b/pitfall/ptest/test16.coffee @@ -18,3 +18,6 @@ doc = new PDFDocument({compress: no}) doc.pipe(fs.createWriteStream('test16.pdf')) make doc +doc = new PDFDocument({compress: yes}) +doc.pipe(fs.createWriteStream('test16c.pdf')) +make doc \ No newline at end of file diff --git a/pitfall/ptest/test16.pdf b/pitfall/ptest/test16.pdf index 4de8a15c..c1bdd145 100644 Binary files a/pitfall/ptest/test16.pdf and b/pitfall/ptest/test16.pdf differ diff --git a/pitfall/ptest/test16.rkt b/pitfall/ptest/test16.rkt index 8e39d3b0..fcc119e9 100644 --- a/pitfall/ptest/test16.rkt +++ b/pitfall/ptest/test16.rkt @@ -20,4 +20,4 @@ (make-doc this #f proc) (define-runtime-path that "test16crkt.pdf") -(make-doc that #t proc #:pdfkit #f) \ No newline at end of file +(make-doc that #t proc) \ No newline at end of file diff --git a/pitfall/ptest/test16c.pdf b/pitfall/ptest/test16c.pdf new file mode 100644 index 00000000..63be8d21 Binary files /dev/null and b/pitfall/ptest/test16c.pdf differ diff --git a/pitfall/ptest/test16crkt.pdf b/pitfall/ptest/test16crkt.pdf new file mode 100644 index 00000000..687c8d2e Binary files /dev/null and b/pitfall/ptest/test16crkt.pdf differ diff --git a/pitfall/ptest/test16rkt.pdf b/pitfall/ptest/test16rkt.pdf new file mode 100644 index 00000000..314bbe47 Binary files /dev/null and b/pitfall/ptest/test16rkt.pdf differ diff --git a/pitfall/ptest/test17.coffee b/pitfall/ptest/test17.coffee index afdecfd7..1bcd4e03 100644 --- a/pitfall/ptest/test17.coffee +++ b/pitfall/ptest/test17.coffee @@ -18,3 +18,6 @@ doc = new PDFDocument({compress: no}) doc.pipe(fs.createWriteStream('test17.pdf')) make doc +doc = new PDFDocument({compress: yes}) +doc.pipe(fs.createWriteStream('test17c.pdf')) +make doc \ No newline at end of file diff --git a/pitfall/ptest/test17.pdf b/pitfall/ptest/test17.pdf index 625bafc8..1b0fc1a6 100644 Binary files a/pitfall/ptest/test17.pdf and b/pitfall/ptest/test17.pdf differ diff --git a/pitfall/ptest/test17.rkt b/pitfall/ptest/test17.rkt index 989b1383..2383b0d8 100644 --- a/pitfall/ptest/test17.rkt +++ b/pitfall/ptest/test17.rkt @@ -20,4 +20,4 @@ (make-doc this #f proc) (define-runtime-path that "test17crkt.pdf") -(make-doc that #t proc #:pdfkit #f) \ No newline at end of file +(make-doc that #t proc) \ No newline at end of file diff --git a/pitfall/ptest/test17c.pdf b/pitfall/ptest/test17c.pdf new file mode 100644 index 00000000..24404ae0 Binary files /dev/null and b/pitfall/ptest/test17c.pdf differ diff --git a/pitfall/ptest/test17crkt.pdf b/pitfall/ptest/test17crkt.pdf new file mode 100644 index 00000000..6d467cd7 Binary files /dev/null and b/pitfall/ptest/test17crkt.pdf differ diff --git a/pitfall/ptest/test17rkt.pdf b/pitfall/ptest/test17rkt.pdf new file mode 100644 index 00000000..45e6d6c1 Binary files /dev/null and b/pitfall/ptest/test17rkt.pdf differ