From 625cd7c92db463575cd6f2a47ff5a986bbfb5f49 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 4 Apr 2017 17:51:03 -0700 Subject: [PATCH] stuck --- pitfall/pitfall/minimal-annotation.rkt | 42 ++++++++++++++++++++++---- pitfall/pitfall/render.rkt | 8 +++-- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/pitfall/pitfall/minimal-annotation.rkt b/pitfall/pitfall/minimal-annotation.rkt index a815a736..17ccd103 100644 --- a/pitfall/pitfall/minimal-annotation.rkt +++ b/pitfall/pitfall/minimal-annotation.rkt @@ -10,7 +10,9 @@ (co-io 3 0 (co-page #:parent (co-io-ref 2 0) #:mediabox '(0 0 612 792) #:resources (co-io-ref 4 0) - #:contents (co-io-ref 5 0))) + #:contents (co-io-ref 5 0) + )) +#;#:annots (co-io-ref 7 0) ;; resources (co-io 4 0 @@ -18,11 +20,6 @@ 'ProcSet (co-array '(PDF Text)) 'Font (make-co-dict 'F1 (co-io-ref 6 0)))) -;; font -(co-io 6 0 - (make-co-dict - 'Type 'Font 'Subtype 'Type1 'Name 'F1 'BaseFont 'Helvetica)) - ;; contents (co-io 5 0 (make-co-stream @@ -32,3 +29,36 @@ (Hello World)Tj ET")) + +;; font +(co-io 6 0 + (make-co-dict + 'Type 'Font 'Subtype 'Type1 'Name 'F1 'BaseFont 'Helvetica)) + +;; annots +#| +(co-io 7 0 + (co-array (list (co-io-ref 8 0))) + +(co-io 8 0 + (co-dict + (hasheq + 'Rect + (co-array '(260 596.0184 404.048 613.331)) + 'Subtype + 'StrikeOut + 'Contents + "" + 'F + 4 + 'M + "D:20170405003853Z00'00'" + 'Type + 'Annot + 'C + (co-array '(0.8945577 0.05464891 0.07036456)) + 'AP + (co-io-ref 11 0) + 'QuadPoints + (co-array '(260 613.331 404.048 613.331 260 596.0184 404.048 596.0184))))) +|# \ No newline at end of file diff --git a/pitfall/pitfall/render.rkt b/pitfall/pitfall/render.rkt index 0c248116..987c1b44 100644 --- a/pitfall/pitfall/render.rkt +++ b/pitfall/pitfall/render.rkt @@ -34,7 +34,7 @@ (if (co-io? cosexpr) (cons (cons (co-io-idx cosexpr) offset) io-locs) io-locs)))) - (define header-str (cosexpr->bytes (co-header "%PDF-1.1\n%¥±ë"))) + (define header-str (cosexpr->bytes (co-header "%PDF-1.3\n%¥±ë"))) (define trailer-str (cosexpr->bytes (co-trailer (co-dict (hasheq 'Size (length bstrs) 'Root (co-io-ref 1 0)))))) (define last-offset (for/sum ([bstr (in-list bstrs)]) @@ -107,12 +107,14 @@ (define (co-page #:parent parent #:mediabox pts #:resources [rsrcs (co-dict (hasheq))] - #:contents contents) + #:contents contents + #:annots [annots (co-array null)]) (co-dict (hasheq 'Type 'Page 'Parent parent 'MediaBox (co-array pts) 'Resources rsrcs - 'Contents contents))) + 'Contents contents + 'Annots annots))) (define (make-co-dict . xs) (co-dict (apply hasheq xs)))