Module: Prawn::Document::Internals
- Included in:
- Prawn::Document
- Defined in:
- lib/prawn/document/internals.rb
Overview
This module exposes a few low-level PDF features for those who want to extend Prawn’s core functionality. If you are not comfortable with low level PDF functionality as defined by Adobe’s specification, chances are you won’t need anything you find here.
Instance Method Summary collapse
-
#add_content(str) ⇒ Object
Appends a raw string to the current page content.
-
#page_fonts ⇒ Object
The Font dictionary for the current page.
-
#page_resources ⇒ Object
The Resources dictionary for the current page.
-
#page_xobjects ⇒ Object
The XObject dictionary for the current page.
-
#proc_set(*types) ⇒ Object
Add a new type to the current pages ProcSet.
-
#ref(data) ⇒ Object
Creates a new Prawn::Reference and adds it to the Document’s object list.
Instance Method Details
#add_content(str) ⇒ Object
Appends a raw string to the current page content.
# Raw line drawing example:
x1,y1,x2,y2 = 100,500,300,550
pdf.add_content("%.3f %.3f m" % [ x1, y1 ]) # move
pdf.add_content("%.3f %.3f l" % [ x2, y2 ]) # draw path
pdf.add_content("S") # stroke
25 26 27 |
# File 'lib/prawn/document/internals.rb', line 25 def add_content(str) @page_content << str << "\n" end |
#page_fonts ⇒ Object
The Font dictionary for the current page
44 45 46 |
# File 'lib/prawn/document/internals.rb', line 44 def page_fonts page_resources[:Font] ||= {} end |
#page_resources ⇒ Object
The Resources dictionary for the current page
38 39 40 |
# File 'lib/prawn/document/internals.rb', line 38 def page_resources @current_page.data[:Resources] ||= {} end |
#page_xobjects ⇒ Object
The XObject dictionary for the current page
49 50 51 |
# File 'lib/prawn/document/internals.rb', line 49 def page_xobjects page_resources[:XObject] ||= {} end |
#proc_set(*types) ⇒ Object
Add a new type to the current pages ProcSet
31 32 33 34 |
# File 'lib/prawn/document/internals.rb', line 31 def proc_set(*types) @current_page.data[:ProcSet] ||= ref([]) @current_page.data[:ProcSet].data |= types end |
#ref(data) ⇒ Object
Creates a new Prawn::Reference and adds it to the Document’s object list. The data
argument is anything that Prawn::PdfObject() can convert.
13 14 15 |
# File 'lib/prawn/document/internals.rb', line 13 def ref(data) @objects.push(Prawn::Reference.new(@objects.size + 1, data)).last end |