diff --git a/pitfall/pitfall/core.rkt b/pitfall/pitfall/core.rkt index 4becb775..b796effc 100644 --- a/pitfall/pitfall/core.rkt +++ b/pitfall/pitfall/core.rkt @@ -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)) diff --git a/pitfall/pitfall/pdf.rkt b/pitfall/pitfall/pdf.rkt index c41751fa..b39905ab 100644 --- a/pitfall/pitfall/pdf.rkt +++ b/pitfall/pitfall/pdf.rkt @@ -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")) diff --git a/pitfall/pitfall/pdftest.rkt b/pitfall/pitfall/pdftest.rkt index 4cb296ac..db8c19ec 100644 --- a/pitfall/pitfall/pdftest.rkt +++ b/pitfall/pitfall/pdftest.rkt @@ -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)) diff --git a/pitfall/pitfall/reference.rkt b/pitfall/pitfall/reference.rkt index e85c4f07..b534d13f 100644 --- a/pitfall/pitfall/reference.rkt +++ b/pitfall/pitfall/reference.rkt @@ -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])))