PDF Document creator
PDF Document creator
fontname
- default: Helvetica. Choose one of the standard PDF
fonts: Times-Roman, Times-Bold,
Times-Italic, Times-BoldItalic, Helvetica, Helvetica-Bold, Helvetica-Oblique,
Helvetica-BoldOblique, Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique,
Symbol, ZapfDingbats
width.height
document dimensions. Default 400x400
version
Default: 1.2. Doesn't do anything other than set the string at the
beginning of the PDF document.
...
PDF objects
version
PDF spec version
width, height
document width and height
user_objects
User elements added to the document
setup_objects
standard PDF header objects not directly defined by the user Initialize a new PDF documentConfigure the setup objects and initialise the user_objects The setup objects are those PDF objects needed to initialise the page at the most basic level i.e.
set up a catalog
set up a list of pages
set up font information.
set up the list of page contents (which will get updated with each new object)
keep track of GraphicStates used by various objects
width, height
document width and height
all_objects
List containing all objects
objs
All strings for all objects
header
The header for this document
body
The body is just the collection of all objects
xref
Update a xref table based upon the current objectsand the offsets to the start of each object Each xref entry must be exactly 20bytes (include CRLF). Since I'm only using CR, I need to add an extra space at the end of each xref entry
offsets
For the XREF table, need to know the offset to each object from start of document
trailer
The trailer indicates the start of the XREF table and total length of all objects it represents (including the dummy/root object)
new()
PDFDocument$new( ..., width = 400, height = 400, fontname = "Helvetica", version = 1.2 )
...
user objects to add during initialisation
width, height
dimensions of PDF document
fontname
default font for document (Default: 'Helvetica')
version
PDF specifcation version. Default: 1.2 Append user-defined objects to document
append()
PDFDocument$append(..., position = NULL)
...
objects
position
where should the objects be inserted in the user object list? Default: NULL means to append at end of object list. A value of "1" means to insert at start of object list. Replace an object at the given position
replace()
PDFDocument$replace(pdf_object, position)
pdf_object
User defined PDF object e.g. TODO
position
numeric index in object list Delete the object at the given position
delete()
PDFDocument$delete(position)
position
numeric index in object list Character reprsetntatino of PDF document as a single string
as_character()
PDFDocument$as_character(...)
...
ignored Print
print()
PDFDocument$print(...)
...
ignored Save to PDF file
save()
PDFDocument$save(filename, ...)
filename
output filename
...
ignored
copy()
Deep copy of this document Show the PDF in the defined R viewer
PDFDocument$copy()
show()
viewer
which viewer to use
text()
Initialize a stream object representing a text
PDFDocument$text(text, x, y, fontsize, text_mode, ...)
text
text
x, y
location
fontsize, text_mode
text settings [optional]
...
initial named attributes of this object
rect()
Initialize a stream object representing a rectangle
PDFDocument$rect(x, y, width, height, ...)
x, y, width, height
specificaiton of rectangle extents
...
initial named attributes of this object
line()
Initialize a stream object representing a line
PDFDocument$line(x1, y1, x2, y2, ...)
x1, y1, x2, y2
line start/end coordinates
...
initial named attributes of this object
circle()
Initialize a stream object representing a circle
PDFDocument$circle(x, y, r, ...)
x, y
centre of circle
r
radius
...
initial named attributes of this object
polygon()
Initialize a stream object representing a polygon
PDFDocument$polygon(xs, ys, ...)
xs, ys
coordinates of polygon vertices
...
initial named attributes of this object
polyline()
Initialize a stream object representing a polyline
PDFDocument$polyline(xs, ys, ...)
xs, ys
numeric vectors of x, ycoordinates along polyline
...
initial named attributes of this object
custom()
Initialize a stream object representing a custom object with text
PDFDocument$custom(text, new_graphics_state = TRUE, ...)
text
text string
new_graphics_state
Should the object be drawn in its own local graphics state? default: TRUE
...
initial named attributes of this object Initialize a new PDF Dict
dict()
PDFDocument$dict(...)
...
named objects to add to dictionary
clone()
The objects of this class are cloneable with this method.
PDFDocument$clone(deep = FALSE)
deep
Whether to make a deep clone.