diff --git a/pitfall/pitfall/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt index 433ccc28..eddb2d70 100644 --- a/pitfall/pitfall/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -70,15 +70,17 @@ [(regexp-try-match #px"^\\s*stream\n" ip) (define stream-length (read (open-input-bytes (cdr (assoc #"/Length" dic))))) - (define stream (read-bytes stream-length ip)) (define compressed? (equal? (dict-ref dic #"/Filter" #f) #"/FlateDecode")) + (define stream ((if compressed? zlib:inflate values) (read-bytes stream-length ip))) + ;; font subsets have their own interior structure, so ignore (maybe too lenient) + (define font? (equal? (subbytes stream 0 4) #"true")) (dict-update (append dic - (list (cons 'stream (if compressed? - (zlib:inflate stream) - stream)))) + (list (cons 'stream (if font? #"0" stream)))) ;; compressed length may vary, so just set to #"0" - #"/Length" (λ (val) (if compressed? #"0" val)))] + #"/Length" (λ (val) (cond + [(or font? compressed?) #"0"] + [else val])))] [else dic])] [else (pat-lex ip @@ -88,6 +90,7 @@ ["[-]?\\d*\\.\\d+"] ; real ["[-]?\\d+\\.?"] ; integer ["\\(.*?\\)"] ; parenstring + ["/[A-Z]{6}(\\+\\w+)" => cadr] ; font keystring. prefix is random, so ignore ["/\\S+"] ; keystring [else eof])])) diff --git a/pitfall/ptest/test12.rkt b/pitfall/ptest/test12.rkt index 32fc8117..efdf539e 100644 --- a/pitfall/ptest/test12.rkt +++ b/pitfall/ptest/test12.rkt @@ -19,4 +19,4 @@ (make-doc this #f proc) (define-runtime-path that "test12crkt.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/test12crkt copy.pdf b/pitfall/ptest/test12crkt copy.pdf index 9dbce0bc..b1ad1586 100644 Binary files a/pitfall/ptest/test12crkt copy.pdf and b/pitfall/ptest/test12crkt copy.pdf differ diff --git a/pitfall/ptest/test12rkt copy.pdf b/pitfall/ptest/test12rkt copy.pdf index 4f208f60..d333778e 100644 Binary files a/pitfall/ptest/test12rkt copy.pdf and b/pitfall/ptest/test12rkt copy.pdf differ diff --git a/pitfall/ptest/test13.rkt b/pitfall/ptest/test13.rkt index 7fa3a00d..ba3f5bac 100644 --- a/pitfall/ptest/test13.rkt +++ b/pitfall/ptest/test13.rkt @@ -18,11 +18,4 @@ (make-doc this #f proc) (define-runtime-path that "test13crkt.pdf") -(make-doc that #t proc #:pdfkit #f) - -#;(module+ test - (define doc (make-object PDFDocument)) - (send doc registerFont "Charter" (path->string charter-path)) - (send* doc [font "Charter"]) - (send doc pipe (open-output-string)) - (send doc end)) +(make-doc that #t proc)