more params

main
Matthew Butterick 6 years ago
parent a8a0e3b6d3
commit 7870e8aad3

@ -1,6 +1,5 @@
#lang debug at-exp racket/base #lang debug at-exp racket/base
(require (require
"helper.rkt"
"param.rkt" "param.rkt"
"struct.rkt" "struct.rkt"
racket/class racket/class
@ -25,7 +24,8 @@
(define mixed% (annotation-mixin (image-mixin (text-mixin (fonts-mixin (color-mixin (vector-mixin object%))))))) (define mixed% (annotation-mixin (image-mixin (text-mixin (fonts-mixin (color-mixin (vector-mixin object%)))))))
(define-subclass mixed% (PDFDocument [options (mhash)]) (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) (current-doc-offset 0)
(field [doc-byte-strings empty] (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 (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 ;; 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)]) (define/contract (addPage this [options-arg (· this options)])

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

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

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

Loading…
Cancel
Save