diff --git a/pitfall/pitfall/kit/document.rkt b/pitfall/pitfall/kit/document.rkt index a2eb1fd6..e71c4a3d 100644 --- a/pitfall/pitfall/kit/document.rkt +++ b/pitfall/pitfall/kit/document.rkt @@ -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) diff --git a/pitfall/pitfall/kit/helper.rkt b/pitfall/pitfall/kit/helper.rkt index 4587603f..7ec75985 100644 --- a/pitfall/pitfall/kit/helper.rkt +++ b/pitfall/pitfall/kit/helper.rkt @@ -54,4 +54,11 @@ (define isBuffer? bytes?) (define (newBuffer x) (string->bytes/latin-1 (format "~a" x))) -(define buffer-length bytes-length) \ No newline at end of file +(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))) \ No newline at end of file diff --git a/pitfall/pitfall/kit/mixins/vector.rkt b/pitfall/pitfall/kit/mixins/vector.rkt index 55456d48..137ce2c1 100644 --- a/pitfall/pitfall/kit/mixins/vector.rkt +++ b/pitfall/pitfall/kit/mixins/vector.rkt @@ -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 \ No newline at end of file + (send this addContent "1 0 0 -1 0 792 cm")))) ; todo debug \ No newline at end of file diff --git a/pitfall/pitfall/kit/reference.rkt b/pitfall/pitfall/kit/reference.rkt index 2bed4bfd..f64ce32c 100644 --- a/pitfall/pitfall/kit/reference.rkt +++ b/pitfall/pitfall/kit/reference.rkt @@ -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")))) diff --git a/pitfall/pitfall/kit/zzz.pdf b/pitfall/pitfall/kit/zzz.pdf index 778e96a9..e2708d61 100644 --- a/pitfall/pitfall/kit/zzz.pdf +++ b/pitfall/pitfall/kit/zzz.pdf @@ -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 <<