achievement

main
Matthew Butterick 8 years ago
parent 43ff762c2d
commit 811a58c961

@ -100,7 +100,7 @@
;; create a page object
(set! @page (make-object PDFPage this options))
(push! @_pageBuffer @page)
(push-end @_pageBuffer @page)
;; add the page to the object store
(define pages (· @_root data Pages data))
(hash-update! pages 'Kids (λ (val) (cons (· @page dictionary) val)) null)
@ -133,7 +133,7 @@
(public [@ref ref])
(define (@ref [data (make-hasheq)])
(define ref (make-object PDFReference this (add1 (length @_offsets)) data))
(push! @_offsets #f) ; placeholder for this object's offset once it is finalized
(push-end @_offsets (* 1000 (add1 (length @_offsets)))) ; placeholder for this object's offset once it is finalized
(++ @_waiting)
ref)
@ -155,10 +155,12 @@
this)
(define/public (_refEnd ref)
(report* @_offsets (· ref id) (· ref offset))
(set! @_offsets (for/list ([(offset idx) (in-indexed @_offsets)])
(if (= idx (sub1 (· ref id)))
(if (= (sub1 (· ref id)) idx)
(· ref offset)
offset)))
(report* @_offsets)
(-- @_waiting)
(if (and (zero? @_waiting) @_ended)
(@_finalize)

@ -54,4 +54,11 @@
(define isBuffer? bytes?)
(define (newBuffer x) (string->bytes/latin-1 (format "~a" x)))
(define buffer-length bytes-length)
(define buffer-length bytes-length)
(define-syntax-rule (push-end id thing) (set! id (append id (list thing))))
(module+ test
(define xs '(1 2 3))
(push-end xs 4)
(check-equal? xs '(1 2 3 4)))

@ -11,4 +11,4 @@
(define/public (initVector) (void))
(define/public (transform m11 m12 m21 m22 dx dy)
(send this addContent "1 0 0 -1 0 792 cm")))) ; todo
(send this addContent "1 0 0 -1 0 792 cm")))) ; todo debug

@ -25,7 +25,6 @@
(_write data #f void))
(define/public (_write chunk-in encoding callback)
(report 'boom)
(define chunk (if (isBuffer? chunk-in)
chunk-in
(newBuffer (string-append chunk-in "\n"))))

@ -26,7 +26,7 @@ endobj
6 0 obj
<<
/Producer (PDFKit)
/CreationDate (D:20170512220606Z)
/CreationDate (D:20170512224816Z)
/Creator (PDFKit)
>>
endobj
@ -48,9 +48,9 @@ xref
0000000000 65535 f
0000000395 00000 n
0000000346 00000 n
0000057005 00000 n
0000000186 00000 n
0000000119 00000 n
0000000015 00000 n
0000000254 00000 n
trailer
<<

Loading…
Cancel
Save