Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
web:pdf [2019/06/06 01:50]
agcyphers
web:pdf [2020/02/22 08:06] (current)
agcyphers [Methods]
Line 7: Line 7:
 ==== Contants ==== ==== Contants ====
 ^ Name      ^ Value       ^ ^ Name      ^ Value       ^
-| FormatA3 as [[http://developer.xojo.com/string|String]] | "a3"+| FormatA3 as String | "a3"
-| FormatA4 as [[http://developer.xojo.com/string|String]] | "a4"+| FormatA4 as String | "a4"
-| FormatA5 as [[http://developer.xojo.com/string|String]] | "a5"+| FormatA5 as String | "a5"
-| FormatLegal as [[http://developer.xojo.com/string|String]] | "legal"+| FormatLegal as String | "legal"
-| FormatLetter as [[http://developer.xojo.com/string|String]] | "letter" |+| FormatLetter as String | "letter" |
 | LineStyleBevel as Number | 0 | | LineStyleBevel as Number | 0 |
 | LineStyleRound as Number | 1 | | LineStyleRound as Number | 1 |
 | LineStyleSquare as Number | 2 | | LineStyleSquare as Number | 2 |
-| OrientationLandscape as [[http://developer.xojo.com/string|String]] | "landscape"+| OrientationLandscape as String | "landscape"
-| OrientationPortrait as [[http://developer.xojo.com/string|String]] | "portrait"+| OrientationPortrait as String | "portrait"
-| UnitCentimeters as [[http://developer.xojo.com/string|String]] | "cm"+| UnitCentimeters as String | "cm"
-| UnitInches as [[http://developer.xojo.com/string|String]] | "in"+| UnitInches as String | "in"
-| UnitMillimeters as [[http://developer.xojo.com/string|String]] | "mm"+| UnitMillimeters as String | "mm"
-| UnitPoints as [[http://developer.xojo.com/string|String]] | "pt" |+| UnitPoints as String | "pt" |
 ==== Events ==== ==== Events ====
 ^ Definition      ^ Description       ^ ^ Definition      ^ Description       ^
-| PDFOutput( theContent as [[http://developer.xojo.com/string|String]] ) | Fired when the PDF content has been generated.  theContent is a BASE64 compatible URI. |+| PDFOutput( theContent as String ) | Fired when the PDF content has been generated.  theContent is a BASE64 compatible URI. | 
 +| TableUpdated( theTable as GraffitiWebPDFTable) | Raised when a table has been added to the document and its StartY and EndY properties are populated. |
 ==== Methods ==== ==== Methods ====
 ^ Definition      ^ Description       ^ ^ Definition      ^ Description       ^
-| AddBezier( StartX as [[http://developer.xojo.com/double|Double]], StartY as [[http://developer.xojo.com/double|Double]], X1 as [[http://developer.xojo.com/double|Double]], Y1 as [[http://developer.xojo.com/double|Double]], X2 as [[http://developer.xojo.com/double|Double]], Y2 as [[http://developer.xojo.com/double|Double]], X3 as [[http://developer.xojo.com/double|Double]], Y3 as [[http://developer.xojo.com/double|Double]] ) | Add a bezier curve to the PDF. | +| AddBezier( StartX as Double, StartY as Double, _ \\ X1 as Double, Y1 as Double, _ \\ X2 as Double, Y2 as Double, _ \\ X3 as Double, Y3 as Double ) | Add a bezier curve to the PDF. | 
-| AddCircle( X as [[http://developer.xojo.com/double|Double]], Y as [[http://developer.xojo.com/double|Double]], Radius as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Add a circle to the PDF. | +| AddCircle( X as Double, Y as Double, _ \\ Radius as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Add a circle to the PDF. | 
-| AddEllipse( X as [[http://developer.xojo.com/double|Double]], Y as [[http://developer.xojo.com/double|Double]], RadiusX as [[http://developer.xojo.com/double|Double]], RadiusY as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Add an ellipse to the PDF. | +| AddEllipse( X as Double, Y as Double, _ \\ RadiusX as Double, RadiusY as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Add an ellipse to the PDF. | 
-| AddHTML( HTMLContent as [[http://developer.xojo.com/string|String]], W as [[http://developer.xojo.com/integer|Integer]] = 1200 ) | Add HTML to the PDF.  W is the width of the area to render on. | +| AddHTML( HTMLContent as String, W as Integer = 1200 ) | Add HTML to the PDF.  W is the width of the area to render on. | 
-| AddImage( PictureData as [[http://developer.xojo.com/string|String]], Type as [[http://developer.xojo.com/string|String]], X as [[http://developer.xojo.com/double|Double]], Y as [[http://developer.xojo.com/double|Double]], W as [[http://developer.xojo.com/double|Double]] = - 1, H as [[http://developer.xojo.com/double|Double]] = - 1 ) | Add an image to the PDF.  PictureData should be a BASE64 compatible URI string. | +| AddImage( PictureData as String, Type as String, _ \\ X as Double, Y as Double, _ \\ W as Double = - 1, H as Double = - 1 ) | Add an image to the PDF.  PictureData should be a BASE64 compatible URI string. | 
-| AddLine( X1 as [[http://developer.xojo.com/double|Double]], Y1 as [[http://developer.xojo.com/double|Double]], X2 as [[http://developer.xojo.com/double|Double]], Y2 as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Draws a line on the PDF. | +| AddLine( X1 as Double, Y1 as Double, _ \\ X2 as Double, Y2 as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Draws a line on the PDF. | 
-| AddPage( W as [[http://developer.xojo.com/double|Double]] = 210, H as [[http://developer.xojo.com/double|Double]] = 297 ) | Adds a page to the PDF.  W and H are dimensions. | +| AddPage( W as Double = 210, H as Double = 297 ) | Adds a page to the PDF.  W and H are dimensions. | 
-| AddRect( X as [[http://developer.xojo.com/double|Double]], Y as [[http://developer.xojo.com/double|Double]], W as [[http://developer.xojo.com/double|Double]], H as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Draws a rectangle on the PDF. | +| AddRect( X as Double, Y as Double, _ \\ W as Double, H as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Draws a rectangle on the PDF. | 
-| AddRoundedRect( X as [[http://developer.xojo.com/double|Double]], Y as [[http://developer.xojo.com/double|Double]], W as [[http://developer.xojo.com/double|Double]], H as [[http://developer.xojo.com/double|Double]], RadiusX as [[http://developer.xojo.com/double|Double]], RadiusY as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Draws a rounded rectangle on the PDF. |+| AddRoundedRect( X as Double, Y as Double, _ \\ W as Double, H as Double, _ \\ RadiusX as Double, RadiusY as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Draws a rounded rectangle on the PDF. |
 | AddTable( Data as GraffitiWebPDFTable ) | Draws a table on the PDF. | | AddTable( Data as GraffitiWebPDFTable ) | Draws a table on the PDF. |
-| AddText( theContent as [[http://developer.xojo.com/string|String]], X as [[http://developer.xojo.com/integer|Integer]], Y as [[http://developer.xojo.com/integer|Integer]], BlockWidth as [[http://developer.xojo.com/double|Double]] = -1 ) | Draws text on the PDF. | +| AddText( theContent as String, X as Integer, Y as Integer, BlockWidth as Double = -1 ) | Draws text on the PDF. | 
-| AddTriangle( X1 as [[http://developer.xojo.com/double|Double]], Y1 as [[http://developer.xojo.com/double|Double]], X2 as [[http://developer.xojo.com/double|Double]], Y2 as [[http://developer.xojo.com/double|Double]], X3 as [[http://developer.xojo.com/double|Double]], Y3 as [[http://developer.xojo.com/double|Double]], hasFill as [[http://developer.xojo.com/boolean|Boolean]] = False, hasStroke as [[http://developer.xojo.com/boolean|Boolean]] = False ) | Draws a triangle on the PDF. | +| AddTriangle( X1 as Double, Y1 as Double, _ \\ X2 as Double, Y2 as Double, _ \\ X3 as Double, Y3 as Double, _ \\ hasFill as Boolean = False, hasStroke as Boolean = False ) | Draws a triangle on the PDF. | 
-| Download( Filename as [[http://developer.xojo.com/string|String]] ) | Constructs the PDF and sends it to the browser for download. | +| Download( Filename as String ) | Constructs the PDF and sends it to the browser for download. | 
-| FromHTML( theHTML as String,DocumentOrientation as String = "portrait", DocumentUnits as String = "pt", DocumentFormat as String = "letter", Margin as Double = 0 ) | Creates a PDF from an HTML string. |+| FromHTML( theHTML as String,DocumentOrientation as String = "portrait", _ \\ DocumentUnits as String = "pt", DocumentFormat as String = "letter", _ \\ Margin as Double = 0 ) | Creates a PDF from an HTML string. |
 | GetTable( tableID as String ) As GraffitiWebPDFTable | Gets an added table object. | | GetTable( tableID as String ) As GraffitiWebPDFTable | Gets an added table object. |
-| LoadInViewer( theViewer as WebHTMLViewer, theContent as [[http://developer.xojo.com/string|String]] ) | Will load the output of the PDFOutput event in to a WebHTMLViewer. | +| LoadInViewer( theViewer as WebHTMLViewer, theContent as String ) | Will load the output of the PDFOutput event in to a WebHTMLViewer. | 
-| NewDocument( DocumentOrientation as [[http://developer.xojo.com/string|String]] = "portrait", DocumentUnits as [[http://developer.xojo.com/string|String]] = "mm", DocumentFormat as [[http://developer.xojo.com/string|String]] = "A4" ) | Start a new PDF document. |+| NewDocument( DocumentOrientation as String = "portrait", _ \\ DocumentUnits as String = "mm", _ \\ DocumentFormat as String = "A4" ) | Start a new PDF document. |
 | Output() | Tell GraffitiWebPDF to compile and output the data. | | Output() | Tell GraffitiWebPDF to compile and output the data. |
 | Save() ''Deprecated'' | Tells GraffitiWebPDF to compile the PDF data and prompt the user for download. This method has been deprecated as it may not behave properly across all browsers. | | Save() ''Deprecated'' | Tells GraffitiWebPDF to compile the PDF data and prompt the user for download. This method has been deprecated as it may not behave properly across all browsers. |
-| SetFillColor( theColor as [[http://developer.xojo.com/color|Color]] ) | Changes the document's Fill Color for items added after calling this method. |  +| SetFillColor( theColor as Color ) | Changes the document's Fill Color for items added after calling this method. |  
-| SetFillColor( Gray as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetFillColor( Gray as Integer ) | ::: | 
-| SetFillColor( Red as [[http://developer.xojo.com/integer|Integer]], Green as [[http://developer.xojo.com/integer|Integer]], Blue as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetFillColor( Red as Integer, Green as Integer, Blue as Integer ) | ::: | 
-| SetFillColor( Cyan as [[http://developer.xojo.com/integer|Integer]], Magenta as [[http://developer.xojo.com/integer|Integer]], Yellow as [[http://developer.xojo.com/integer|Integer]], Key as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetFillColor( Cyan as Integer, Magenta as Integer, Yellow as Integer, Key as Integer ) | ::: | 
-| SetFont( Face as [[http://developer.xojo.com/string|String]], Style as [[http://developer.xojo.com/string|String]] ) | Changes the document's font face and style for items added after calling this method. | +| SetFont( Face as String, Style as String ) | Changes the document's font face and style for items added after calling this method. | 
-| SetFontSize( newSize as [[http://developer.xojo.com/double|Double]] ) | Changes the document's font size for items added after calling this method. | +| SetFontSize( newSize as Double ) | Changes the document's font size for items added after calling this method. | 
-| SetFontStyle( Style as [[http://developer.xojo.com/string|String]] ) | Changes the document's font style for items added after calling this method. | +| SetFontStyle( Style as String ) | Changes the document's font style for items added after calling this method. | 
-| SetLineCap( Style as [[http://developer.xojo.com/integer|Integer]] ) | Changes the style of line end caps. | +| SetLineCap( Style as Integer ) | Changes the style of line end caps. | 
-| SetLineJoin( Style as [[http://developer.xojo.com/integer|Integer]] ) | Changes the style of line joints. | +| SetLineJoin( Style as Integer ) | Changes the style of line joints. | 
-| SetLineWidth( W as [[http://developer.xojo.com/double|Double]] ) | Sets the thickness of lines drawn after calling this method. | +| SetLineWidth( W as Double ) | Sets the thickness of lines drawn after calling this method. | 
-| SetPage( PageNumber as [[http://developer.xojo.com/integer|Integer]] ) | Changes the currently selected page within the document. | +| SetPage( PageNumber as Integer ) | Changes the currently selected page within the document. | 
-| SetProperties( Title as [[http://developer.xojo.com/string|String]], Subject as [[http://developer.xojo.com/string|String]] = "", Author as [[http://developer.xojo.com/string|String]] = "", Keywords as [[http://developer.xojo.com/string|String]] = "", Creator as [[http://developer.xojo.com/string|String]] = "GraffitiWebPDF" ) | Sets the properties of the current document. | +| SetProperties( Title as String, Subject as String = "", _ \\ Author as String = "", Keywords as String = "", _ \\ Creator as String = "GraffitiWebPDF" ) | Sets the properties of the current document. | 
-| SetStrokeColor( theColor as [[http://developer.xojo.com/color|Color]] ) | Changes the stroke color for items added to the document after this method is called. |  +| SetStrokeColor( theColor as Color ) | Changes the stroke color for items added to the document after this method is called. |  
-| SetStrokeColor( Gray as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetStrokeColor( Gray as Integer ) | ::: | 
-| SetStrokeColor( Red as [[http://developer.xojo.com/integer|Integer]], Green as [[http://developer.xojo.com/integer|Integer]], Blue as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetStrokeColor( Red as Integer, Green as Integer, Blue as Integer ) | ::: | 
-| SetStrokeColor( Cyan as [[http://developer.xojo.com/integer|Integer]], Magenta as [[http://developer.xojo.com/integer|Integer]], Yellow as [[http://developer.xojo.com/integer|Integer]], Key as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetStrokeColor( Cyan as Integer, Magenta as Integer, Yellow as Integer, Key as Integer ) | ::: | 
-| SetTextColor( theColor as [[http://developer.xojo.com/color|Color]] ) | Changes the text color of items added after this method is called. | +| SetTextColor( theColor as Color ) | Changes the text color of items added after this method is called. | 
-| SetTextColor( Gray as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetTextColor( Gray as Integer ) | ::: | 
-| SetTextColor( Red as [[http://developer.xojo.com/integer|Integer]], Green as [[http://developer.xojo.com/integer|Integer]], Blue as [[http://developer.xojo.com/integer|Integer]] ) | ::: | +| SetTextColor( Red as Integer, Green as Integer, Blue as Integer ) | ::: | 
-| SetTextColor( Cyan as [[http://developer.xojo.com/integer|Integer]], Magenta as [[http://developer.xojo.com/integer|Integer]], Yellow as [[http://developer.xojo.com/integer|Integer]], Key as [[http://developer.xojo.com/integer|Integer]] ) | ::: |+| SetTextColor( Cyan as Integer, Magenta as Integer, Yellow as Integer, Key as Integer ) | ::: |
  
 ==== Properties ==== ==== Properties ====
Line 71: Line 72:
  
 ==== Examples ==== ==== Examples ====
-There are currently no examples for this class.+=== Saving PDFs on the Server === 
 +This is a simple example of saving PDF data to a file on the server. Note that this saves to the same place each time, and could potentially fail based on target and permissions. You should modify this to save each file separately in a safe place. 
 + 
 +This code belongs in the PDFOutput Event Handler on your WebPage or WebContainer. 
 + 
 +<code xojo>dim b64Content as String = theContent.NthField( ",", 2 ) 
 +dim f as FolderItem = GetFolderItem( "newPDF.pdf"
 +if not IsNull( f ) then 
 +  dim b as BinaryStream = BinaryStream.Create( f, True ) 
 +  b.Write( DecodeBase64( b64Content ) ) 
 +  b.Close 
 +end if</code>
  
 ==== Notes ==== ==== Notes ====
Line 79: Line 91:
  
 In ''FromHTML'', you can explicitly add your own page breaks by inserting ''<div class='html2pdf__page-break'></div>'' in your HTML. In ''FromHTML'', you can explicitly add your own page breaks by inserting ''<div class='html2pdf__page-break'></div>'' in your HTML.
 +
 +Due to a BASE64 conversion and display issue in some browsers, PDF files created with FromHTML may not display in an HTMLViewer. These are, however, proper PDFs when downloaded.