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
versionPDF spec version
width, heightdocument width and height
user_objectsUser elements added to the document
setup_objectsstandard 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, heightdocument width and height
all_objectsList containing all objects
objsAll strings for all objects
headerThe header for this document
bodyThe body is just the collection of all objects
xrefUpdate 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
offsetsFor the XREF table, need to know the offset to each object from start of document
trailerThe 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, heightdimensions of PDF document
fontnamedefault font for document (Default: 'Helvetica')
versionPDF specifcation version. Default: 1.2 Append user-defined objects to document
append()PDFDocument$append(..., position = NULL)
...objects
positionwhere 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_objectUser defined PDF object e.g. TODO
positionnumeric index in object list Delete the object at the given position
delete()PDFDocument$delete(position)
positionnumeric 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, ...)
filenameoutput filename
...ignored
copy()Deep copy of this document Show the PDF in the defined R viewer
PDFDocument$copy()
show()viewerwhich viewer to use
text()Initialize a stream object representing a text
PDFDocument$text(text, x, y, fontsize, text_mode, ...)
texttext
x, ylocation
fontsize, text_modetext 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, heightspecificaiton 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, y2line start/end coordinates
...initial named attributes of this object
circle()Initialize a stream object representing a circle
PDFDocument$circle(x, y, r, ...)
x, ycentre of circle
rradius
...initial named attributes of this object
polygon()Initialize a stream object representing a polygon
PDFDocument$polygon(xs, ys, ...)
xs, yscoordinates of polygon vertices
...initial named attributes of this object
polyline()Initialize a stream object representing a polyline
PDFDocument$polyline(xs, ys, ...)
xs, ysnumeric 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, ...)
texttext string
new_graphics_stateShould 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)
deepWhether to make a deep clone.