make kwargs for compress and auto first page

main
Matthew Butterick 6 years ago
parent c8a2e7cb01
commit d649e9986f

@ -44,7 +44,7 @@
;; params
(define test-mode (make-parameter #f))
(define current-compress-streams? (make-parameter #f))
(define current-compress-streams (make-parameter #f))
(define current-pdf-version (make-parameter 1.3))
(define current-auto-first-page (make-parameter #t))

@ -16,7 +16,9 @@
(define (store-ref doc ref)
(set-pdf-refs! doc (cons ref (pdf-refs doc))))
(define (make-pdf [options (make-hasheq)])
(define (make-pdf [options (make-hasheq)]
#:compress [compress? (current-compress-streams)]
#:auto-first-page [auto-first-page? (current-auto-first-page)])
;; initial values
(define pages null)
@ -64,8 +66,8 @@
'Pages (make-ref (mhasheq 'Type 'Pages)))))
;; initialize params
(current-compress-streams? (hash-ref options 'compress #t))
(current-auto-first-page (hash-ref options 'autoFirstPage #t))
(current-compress-streams compress?)
(current-auto-first-page auto-first-page?)
(when (current-auto-first-page) (add-page new-doc))
(when (current-auto-helvetica) (font new-doc "Helvetica"))

@ -37,7 +37,7 @@
(time
(with-output-to-file ps
(λ ()
(define doc (make-pdf (hash 'compress compress?)))
(define doc (make-pdf #:compress compress?))
(start-doc doc)
(proc doc)
(end-doc doc))

@ -31,7 +31,7 @@
(let ([bstr (get-output-bytes ($ref-port ref))])
(cond
[(zero? (bytes-length bstr)) #false]
[(and (current-compress-streams?) (not (hash-ref ($ref-payload ref) 'Filter #f)))
[(and (current-compress-streams) (not (hash-ref ($ref-payload ref) 'Filter #f)))
(hash-set! ($ref-payload ref) 'Filter 'FlateDecode)
(deflate bstr)]
[else bstr])))

Loading…
Cancel
Save