ref → make-ref

main
Matthew Butterick 5 years ago
parent 9195f4218c
commit cc3960a806

@ -36,7 +36,7 @@
(for ([(k v) (in-hash options)])
(hash-set! options (string->symbol (string-titlecase (symbol->string k))) v))
(define annots-ref (send this ref options))
(define annots-ref (send this make-ref options))
(send (· this page) annotations annots-ref)
(· annots-ref end)
this)
@ -46,7 +46,7 @@
((number? number? number? number? string?) (hash?) . ->*m . object?)
(hash-set*! options
'Subtype "Link"
'A (send this ref (mhash 'S "URI"
'A (send this make-ref (mhash 'S "URI"
'URI (String url))))
(send (· options A) end)
(send this annotate x y w h options))

@ -104,7 +104,7 @@
(hash-set! dictionary 'ca fill-opacity))
(when stroke-opacity
(hash-set! dictionary 'CA stroke-opacity))
(define ref-dict (send this ref dictionary))
(define ref-dict (send this make-ref dictionary))
(send ref-dict end)
(set! @opacity-count (add1 @opacity-count))
(list ref-dict (format "Gs~a" @opacity-count)))))

@ -28,8 +28,8 @@
[@ref-gen (generator () (let loop ([refid 1])
(yield refid)
(loop (add1 refid))))]
[@root (ref (mhasheq 'Type "Catalog"
'Pages (ref (mhasheq 'Type "Pages"))))]
[@root (make-ref (mhasheq 'Type "Catalog"
'Pages (make-ref (mhasheq 'Type "Pages"))))]
[(@x x) 0]
[(@y y) 0]
;; initialize the metadata
@ -55,7 +55,7 @@
(define/public (page) (first @pages))
(define/public (ref [payload (mhasheq)])
(define/public (make-ref [payload (mhasheq)])
(define new-ref (make-object PDFReference (@ref-gen) payload))
(set! @refs (cons new-ref @refs))
new-ref)
@ -85,7 +85,7 @@
(for ([page (in-list @pages)])
(send page end))
(define doc-info (ref))
(define doc-info (make-ref))
(for ([(key val) (in-hash @info)])
(dict-set! doc-info key (if (string? val) (String val) val)))
(send doc-info end)

@ -88,7 +88,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(define/override (embed)
;; no CFF support
(define isCFF #false) #;(is-a? subset CFFSubset)
(define font-file (send @document ref))
(define font-file (send @document make-ref))
(when isCFF
(dict-set! font-file 'Subtype "CIDFontType0C"))
@ -115,7 +115,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(integer->char (random 65 (+ 65 26))))))
(define name (string-append tag "+" (font-postscript-name font)))
(define bbox (font-bbox font))
(define descriptor (send @document ref
(define descriptor (send @document make-ref
(mhash
'Type "FontDescriptor"
'FontName name
@ -132,7 +132,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(dict-set! descriptor (if isCFF 'FontFile3 'FontFile2) font-file)
(send descriptor end)
(define descendant-font (send @document ref
(define descendant-font (send @document make-ref
(mhash
'Type "Font"
'Subtype (string-append "CIDFontType" (if isCFF "0" "2"))
@ -159,7 +159,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(define/public (toUnicodeCmap)
(define cmap (send @document ref))
(define cmap (send @document make-ref))
(define entries
(for/list ([idx (in-range (length (hash-keys unicode)))])
(define codepoints (hash-ref unicode idx))

@ -17,7 +17,7 @@
(define/public (ref)
(unless @dictionary
(set! @dictionary (send @document ref)))
(set! @dictionary (send @document make-ref)))
@dictionary)
(define/public (finalize)

@ -48,7 +48,7 @@
(unless (· this obj)
(set-field! obj this
(send doc-in ref
(send doc-in make-ref
(mhash
'Type "XObject"
'Subtype "Image"

@ -55,7 +55,7 @@
(unless (· this obj)
(set-field! obj this
(send doc-in ref
(send doc-in make-ref
(mhash
'Type "XObject"
'Subtype "Image"

@ -18,8 +18,8 @@
(hash-ref page-sizes (string-upcase @size)))]
[(@width width) (list-ref @dimensions (if (equal? @layout "portrait") 0 1))]
[(@height height) (list-ref @dimensions (if (equal? @layout "portrait") 1 0))]
[@content (send @doc ref)]
[(@resources resources) (send @doc ref (mhash 'ProcSet '("PDF" "Text" "ImageB" "ImageC" "ImageI")))]
[@content (send @doc make-ref)]
[(@resources resources) (send @doc make-ref (mhash 'ProcSet '("PDF" "Text" "ImageB" "ImageC" "ImageI")))]
[(@margins margins)
(let ([margin-value (hash-ref @options 'margin #f)])
(if (number? margin-value)
@ -27,7 +27,7 @@
(hash-ref @options 'margins (current-default-margins))))]
;; The page dictionary
[(@dictionary dictionary)
(send @doc ref
(send @doc make-ref
(mhash 'Type "Page"
'Parent @page-parent
'MediaBox (list 0 0 @width @height)

@ -34,7 +34,7 @@
(unless (· this obj)
(set-field! obj this
(send (· this document) ref
(send (· this document) make-ref
(mhash 'Type "XObject"
'Subtype "Image"
'BitsPerComponent (· this image bits)
@ -43,7 +43,7 @@
'Filter "FlateDecode")))
(unless (· this image hasAlphaChannel)
(define params (send (· this document) ref
(define params (send (· this document) make-ref
(mhash 'Predictor 15
'Colors (· this image colors)
'BitsPerComponent (· this image bits)
@ -82,7 +82,7 @@
(when (· this alphaChannel)
(define sMask
(send (· this document) ref
(send (· this document) make-ref
(mhash 'Type "XObject"
'Subtype "Image"
'Height (· this height)

Loading…
Cancel
Save