GraffitiPDF

Enumerations #

This class exposes no enumerations.

Contants #

Name Value
FormatA3 as String “a3”
FormatA4 as String “a4”
FormatA5 as String “a5”
FormatLegal as String “legal”
FormatLetter as String “letter”
LineStyleBevel as Number 0
LineStyleRound as Number 1
LineStyleSquare as Number 2
OrientationLandscape as String “landscape”
OrientationPortrait as String “portrait”
UnitCentimeters as String “cm”
UnitInches as String “in”
UnitMillimeters as String “mm”
UnitPoints as String “pt”

Events #

Definition Parameters Return Type Description
DocumentReady file as GraffitiWebFile = Nil None Fired when the document has been completed.
TableUpdated theTable as GraffitiWebPDFTable None Raised when a table has been added to the document and its StartY and EndY properties are populated.

Methods #

Name Parameters Return Type Description
AddBezier StartX as Double None Add a bezier curve to the PDF.
StartY as Double
X1 as Double
Y1 as Double
X2 as Double
Y2 as Double
X3 as Double
Y3 as Double
AddCircle X as Double None Add a circle to the PDF.
Y as Double
Radius as Double
hasFill as Boolean = False
hasStroke as Boolean = False
AddEllipse X as Double None Add an ellipse to the PDF.
Y as Double
RadiusX as Double
RadiusY as Double
hasFill as Boolean = False
hasStroke as Boolean = False
AddHTML HTMLContent as String None Add HTML to the PDF. W is the width of the area to render on.
W as Integer = 1200
AddImage PictureData as String None Add an image to the PDF. PictureData should be a BASE64 compatible URIstring.
Type as String
X as Double
Y as Double
W as Double = – 1
H as Double = – 1
AddLine X1 as Double None Draws a line on the PDF.
Y1 as Double
X2 as Double
Y2 as Double
hasFill as Boolean = False
hasStroke as Boolean = False
AddPage W as Double = 210 None Adds a page to the PDF. W and H are dimensions.
H as Double = 297
AddRect X as Double None Draws a rectangle on the PDF.
Y as Double
W as Double
H as Double
hasFill as Boolean = False
hasStroke as Boolean = False
AddRoundedRect X as Double None Draws a rounded rectangle on the PDF.
Y as Double
W as Double
H as Double
RadiusX as Double
RadiusY as Double
hasFill as Boolean = False
hasStroke as Boolean = False
AddTable Data as GraffitiWebPDFTable None Draws a table on the PDF.
AddText theContent as String None Draws text on the PDF.
X as Integer
Y as Integer
BlockWidth as Double = -1
AddTriangle X1 as Double None Draws a triangle on the PDF.
Y1 as Double
X2 as Double
Y2 as Double
X3 as Double
Y3 as Double
hasFill as Boolean = False
hasStroke as Boolean = False
Download Filename as String None Constructs the PDF and sends it to the browser for download.
FromHTML theHTML as String None Creates a PDF from an HTML string.
DocumentOrientation as String = “portrait”
DocumentUnits as String = “pt”
DocumentFormat as String = “letter”
Margin as Double = 0
GetTable tableID as String GraffitiWebPDFTable Gets an added table object.
LoadInViewer theViewer as WebHTMLViewer None Will load the output of the PDFOutput event in to a WebHTMLViewer.
theContent as String
NewDocument DocumentOrientation as String = “portrait” None Start a new PDF document.
DocumentUnits as String = “mm”
DocumentFormat as String = “A4”
Output None None Tell GraffitiWebPDF to compile and output the data.
SetFillColor theColor as Color None Changes the document’s Fill Color for items added after calling this method.
SetFillColor Gray as Integer None
SetFillColor Red as Integer None
Green as Integer
Blue as Integer
SetFillColor Cyan as Integer None
Magenta as Integer
Yellow as Integer
Key as Integer
SetFont Face as String None Changes the document’s font face and style for items added after calling this method.
Style as String
SetFontSize newSize as Double None Changes the document’s font size for items added after calling this method.
SetFontStyle Style as String None Changes the document’s font style for items added after calling this method.
SetLineCap Style as Integer None Changes the style of line end caps.
SetLineJoin Style as Integer None Changes the style of line joints.
SetLineWidth W as Double None Sets the thickness of lines drawn after calling this method.
SetPage PageNumber as Integer None Changes the currently selected page within the document.
SetProperties Title as String None Sets the properties of the current document.
Subject as String = “”
Author as String = “”
Keywords as String = “”
Creator as String = “GraffitiWebPDF”
SetStrokeColor theColor as Color None Changes the stroke color for items added to the document after this method is called.
SetStrokeColor Gray as Integer None
SetStrokeColor Red as Integer None
Green as Integer
Blue as Integer
SetStrokeColor Cyan as Integer None
Magenta as Integer
Yellow as Integer
Key as Integer
SetTextColor theColor as Color None Changes the text color of items added after this method is called.
SetTextColor Gray as Integer None
SetTextColor Red as Integer None
Green as Integer
Blue as Integer
SetTextColor Cyan as Integer None
Magenta as Integer
Yellow as Integer
Key as Integer

Properties #

Name Type Default Value Description
AvailableFonts JSONItem Nil The fonts on the user’s machine which are available for use in PDFs.
HasCoverPage Boolean False If True, the PageTemplate will not be applied to the first page and the numbering will shift accordingly to exclude the first page of the document.
PageTemplate GraffitiPDFTemplate Nil Header and footer template to apply to pages.
UploadPath FolderItem Nil Path to save built PDFs to on the server. File are saved in an identifier/year/month/day/name scheme.
UploadPathMakeSafe Boolean True Will attempt to sort returned PDF files in such a way that one user’s uploads will not effect those of another. If you set this to False, generated files will be saved directly in the UploadPath and you may run in to issues in multi-user environments. Sorting these problems out will not be supported as the recommended setting is to leave this property’s value as True.

Examples #

Saving PDFs on the Server #

Defining the UploadPath property will cause generated PDFs to be automatically saved on your server in the path you provide with the following structure:/UploadPath/Session.Identifier/Year/Month/Day/Filename.PDF

Data is not retained in the GraffitiWebFile object to reduce memory usage, and is written directly to the file as it is received.

If UploadPath is Nil then file data will not be transferred back to the server and DocumentReady is only an indicator that you may then safely call the Download, LoadInViewer, and Print methods for client-side functionality.

Notes #

HTML Methods #

The AddHTML and FromHTML methods are currently experimental per the developers of the underlying library. Issues may arise depending on your usage of these methods.

In FromHTML, you can explicitly add your own page breaks by inserting <div class='html2pdf__page-break'></div> in your HTML.