main
Matthew Butterick 6 years ago
parent fbe1525f3c
commit f9757a96aa

@ -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])]))

@ -19,4 +19,4 @@
(make-doc this #f proc)
(define-runtime-path that "test12crkt.pdf")
(make-doc that #t proc #:pdfkit #f)
(make-doc that #t proc)

Binary file not shown.

Binary file not shown.

@ -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)

Loading…
Cancel
Save