more params

main
Matthew Butterick 5 years ago
parent a8a0e3b6d3
commit 7870e8aad3

@ -1,6 +1,5 @@
#lang debug at-exp racket/base
(require
"helper.rkt"
"param.rkt"
"struct.rkt"
racket/class
@ -25,7 +24,8 @@
(define mixed% (annotation-mixin (image-mixin (text-mixin (fonts-mixin (color-mixin (vector-mixin object%)))))))
(define-subclass mixed% (PDFDocument [options (mhash)])
(compress-streams? (hash-ref options 'compress #t))
(current-compress-streams? (hash-ref options 'compress #t))
(current-auto-first-page (hash-ref options 'autoFirstPage #t))
(current-doc-offset 0)
(field [doc-byte-strings empty]
@ -75,7 +75,7 @@
(write this (string-append "%" (list->string (map integer->char (make-list 4 #xFF))))) ; 4 binary chars, as recommended by the spec
;; Add the first page
(when (hash-ref options 'autoFirstPage #t) (addPage this)))
(when (current-auto-first-page) (addPage this)))
(define/contract (addPage this [options-arg (· this options)])

@ -79,8 +79,7 @@
(->m number?)
(- (· this height) (· this margins bottom)))
(define/contract (write this chunk)
(any/c . ->m . void?)
(define (write this chunk)
(send (· this content) write chunk)) ; resume here
(define/contract (end this)

@ -1,7 +1,8 @@
#lang racket/base
(provide (all-defined-out))
(define test-mode (make-parameter #f))
(define 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))
(define current-doc-offset (make-parameter 'doc-offset-not-initialized))

@ -21,8 +21,7 @@
[(? bytes?) x]
[(? input-port?) (port->bytes x)]
[_ (string->bytes/latin-1 (format "~a\n" x))]))
(write-bytes bstr @portal)
(void))
(write-bytes bstr @portal))
(define/public (end [chunk #f])
(when chunk
@ -36,7 +35,7 @@
(let ([bstr (get-output-bytes @portal)])
(cond
[(zero? (bytes-length bstr)) #false]
[(and (compress-streams?) (not (hash-ref @payload 'Filter #f)))
[(and (current-compress-streams?) (not (hash-ref @payload 'Filter #f)))
(hash-set! @payload 'Filter "FlateDecode")
(deflate bstr)]
[else bstr])))

Loading…
Cancel
Save