gPDF

Class (Custom Object)

 
OS X 10.7+
The 'gPDF' class object is designed to provide a way to generate Portable Document Format (PDF) documents while maintaining syntax compatiblity with the existing GRAPHICS object found in Xojo™.   This class object can be used for drawing text, lines, rectangles, ovals, and pictures and then saving the results in a PDF file.  It supports most all of the commands found int the Xojo Graphics object with the exception of those methods and properties noted below [*]. 

Additional there are a few properties added to support PDF requirements, as well as the class supporting properties normally found in a PrinterSetup Object. 

gPDF is custom class written for Xojo allowing the developer to utilize either a PDF destination and/or a normal Xojo Graphics Object with minimal changes to existing code.

Author : R.David Sisemore
  eMail : rdavids3@cox.net
&nbps; Order : webpage

Windows 7 +
Linux[?]
Xojo 2013r3.1+


Properties
AntiAlias*
Author*
Bold
Copies**
FirstPage**
ForeColor
Handle**
Height*
HorizontalResolution*
Italic
Landscape
LastPage**
Left*
PageHeight*
PageLeft*
PageTop*
PageWidth*
PenHeight
PageStyle
PenWidth
PrintingCanceled**
Subject*
TextAscent*
TextFont
TextHeight*
TextSize
TextUnit*
Title*
Top*
Transparency*
Underline
UseOldRenderer*
VerticalResolution*
Version**
Width*
 


The X and Y parameters of the methods are the horizontal and vertical coordinates of the left-top corner of the PDF page being drawn or cleared.  The origin (0,0) is the top-left corner of the page in which the drawing is being done.


Methods
ClearRect
Clip*
Constructor*
DrawCautionIcon*
DrawStopIcon*
DrawLine
DrawNoteIcon*
DrawRect
DrawRoundRect
DrawObject
DrawOval
DrawPicture
DrawPolygon
DrawString
FillOval
FillPolygon
FillRect
FillRoundRect
InitPicture*
Margins*
NextPage
Output*
Pattern*
Pixel*
Reuse*
StringHeight
StringWidth
Watermark*
 


NOTES:  Properites marked above with * are supplied in order to maintain compatiblity with Xojo Graphics object. If called or assigned from an instance of gPDF they will return -1 or False depending on their datatype.

Properties marked above with * apply ONLY to PDF document output, and have no effect otherwise.



DrawObject Shapes
ArcShape
CurveShape
FigureShape
OvalShape
RectShape
RoundRectShape
StringShape
PixMapShape*
Object2D
Group2D
 
 


NOTES: Refer to the Xojo™ documentation for more information about syntax and usage. These object types are processed by the gPDF "DrawObject" procedure.   This version does not support PixMapShape, and the output from StringShape varies from the same output using Xojo Graphic Object commands (for now).


Property Details


Property: AntiAlias* Type: Boolean
pdf.AntiAlias = newBooleanValue
or
BooleanValue = pdf.AntiAlias
NOTE : for backward compatibility only. Always returns FALSE
Property: Author Type: String
pdf.Author = newStringValue
or
StringValue = pdf.Author
Assigns an AUTHORs name which is shown in Inspector window of a PDF Reader
This has no effect if the PDF Output is a Xojo™ Graphics Object
Property: Bold Type: Boolean
pdf.Bold = newBooleanValue
or
BooleanValue = pdf.Bold
If True, applies the bold style to the text content if any.
Note : Not all fonts support BOLD
Property: Copies* Type: Integer

This property is READ-ONLY*

IntegerValue = pdf.Copies
For backwards compatiblity. Always returns 1
Property: FirstPage* Type: Integer

This property is READ-ONLY*

IntegerValue = pdf.FirstPage
For backwards compatiblity. Always returns 1
Property: ForeColor Type: Color
pdf.ForeColor = newColorValue
or
ColorValue = pdf.ForeColor
The currently selected color for the PDF object. This color is used by the various drawing methods.
Note:  Any Alpha/Transparency value included in the color assignments are ignored.
Property: Height Type: Integer

This property is READ-ONLY

IntegerValue = pdf.Height
Returns the Height of the working area of the PDF page, in the units specified.
See Page sizes and margins
Property: HorizontalResolution Type: Integer

This property is READ-ONLY*

IntegerValue = pdf.HorizontalResolution
The horizontal resolution of the PDF object.
NOTE : currently this is fixed at 72DPI
Property: Italic Type: Boolean

pdf.Italic = newBooleanValue
or
BooleanValue = pdf.Italic
If True, applies the italic style to the text content if any.
Note : Not all fonts support Italic
Property: Landscape Type: Boolean

pdf.Landscape = newBooleanValue
or
BooleanValue = pdf.Landscape
Rotates the output 90 degrees. Note : it uses what ever the value in effect is when the OUTPUT() command is issued. All pages will be the same orientation.
Property: LastPage* Type: Integer

This property is READ-ONLY*

IntegerValue = pdf.LastPage
For backwards compatiblity. Always returns 1
Property: Left Type: Double

This property is READ-ONLY*

DoubleValue = pdf.Left
Returns the left margin in the units specified.   This value only has meaning in relation to a PDF page.
See Page sizes and margins
Property: PageHeight Type: Double

This property is READ-ONLY*

IntegerValue = pdf.PageHeight
Returns the height the physical PDF page, in the units specified.
See Page sizes and margins
Property: PageLeft Type: Double

This property is READ-ONLY*

IntegerValue = pdf.PageLeft
Returns the left edge the physical PDF page, in the units specified.
Note : always returns 0
See Page sizes and margins
Property: PageTop Type: Double

This property is READ-ONLY*

IntegerValue = pdf.PageTop
Returns the top edge the physical PDF page, in the units specified.
Note : always returns 0
See Page sizes and margins
Property: PageWidth Type: Double

This property is READ-ONLY

IntegerValue = pdf.PageWidth
Returns the width the physical PDF page, in the units specified.
See Page sizes and margins
Property: PenHeight Type: Integer

pdf.PenHeight = newIntegerValue
or
IntegerValue = pdf.PenHeight
Sets the thickness of lines when drawing.
Note : PenHeight and PenWidth are alias for the same function.
Property: PenStyle Type: Integer

pdf.PenStyle = newIntegerValue
or
IntegerValue = pdf.PenStyle
Sets the dot/dash pattern of a when drawing.
  • [0] SolidtLine    
  • [1] DashLine      
  • [2] DotLine       
  • [3] DashDotLine       
  • [4] DotDotLine       
Property: PenWidth Type: Double

pdf.PenWidth = newDoubleValue
or
IntegerValue = pdf.PenWidth
Sets the thickness of lines when drawing.
Note : PenHeight and PenWidth are alias for the same function.
Property: Subject Type: Integer

pdf.Subject = newStringValue
or
StringValue = pdf.Subject
Assigns a document SUBJECT which is shown in Inspector window of a PDF Reader
This has no effect if the PDF Output is a Xojo™ Graphics Object
Property: TextAscent Type: Double

This property is READ-ONLY*

DoubleValue = pdf.TextAscent
Returns the ascent of a line of text drawn with the current font.
TextAscent is the height of the tallest font letter above the font baseline.
To maintain visual consistency, this is set to be 75% of the TextSize
Property: TextFont Type: String

pdf.TextFont = newStringValue
or
StringValue = pdf.TextFont
This version of gPDF supports only the standard PDF Type 1 fonts.
  • Times-Roman  [Times New Roman, Times Roman]
  • Helvetica    [Arial] Default Font Name
  • Courier      [Courier New]
  • Symbol
  • ZapfDingbats [DingBats]
Property: TextHeight Type: Integer

This property is READ-ONLY*

DoubleValue = pdf.TextHeight
Contains the height of a line of text drawn with the current font.
All measurements are in POINTS.
This value is equal to TEXTSIZE.
Property: TextSize Type: Integer

pdf.TextSize = newDoubleValue
or
DoubleValue = pdf.TextSize
Size of the font used to display the text content
All measurements are in POINTS.
This value is equal to TEXTHEIGHT.
Property: Title Type: String

pdf.Title = newStringValue
or
StringValue = pdf.Title
Assigns a document TITLE which is shown in Inspector window of a PDF Reader
This has no effect if the PDF Output is a Xojo™ Graphics Object
Property: TextUnit* Type: FontUnits

pdf.TextUnit = newDoubleValue
or
DoubleValue = pdf.TextUnit
Note : TextUnit IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
All measurements will be in POINTS.
Property: Top Type: Double

This property is READ-ONLY*

DoubleValue = pdf.Top
Returns the top margin in the units specified.   This value only has meaning in relation to a PDF page.
See Page sizes and margins
Property: Transparency Type: Integer

pdf.Transparency = newDoubleValue
or
DoubleValue = pdf.Transparency
Note : TRANSPARENCY IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Property: Underline Type: Boolean

pdf.Underline = newBooleanValue
or
BooleanValue = pdf.Underline
If True, applies an underline style to the text content if any.
Note : UNDERLINE IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Property: UseOldRenderer Type: Boolean

pdf.UseOldRenderer = newBooleanValue
or
BooleanValue = pdf.UseOldRenderer
Note : UseOldRenderer IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Property: VerticalResolution Type: Integer

This property is READ-ONLY*

IntegerValue = pdf.VerticalResolution
The Vertical resolution of the PDF object.
NOTE : currently this is fixed at 72DPI
Property: Width Type: Double

This property is READ-ONLY

IntegerValue = pdf.Width
Returns the width of the working area of the PDF page, in the units specified.
See Page sizes and margins
Property: Version Type: String

This property is READ-ONLY

StringValue = pdf.Version
Returns a string describing the current version of gPDF


Method Details


Method: ClearRect
PDF.ClearRect(X As Integer,Y As Integer,Width As Integer,Height As Integer)
Clears the rectangle described by the parameters passed by filling it with the background color of the parent window.
Method: Clip*
PDF.Clip(X As Integer,Y As Integer,Width as Integer,Height as Integer)
Note : Clip IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Method: Constructor
myPDFObject=New gPDF
Method: DrawCautionIcon*
PDF.DrawCautionIcon(X As Integer,Y As Integer)
Note : DrawCautionIcon IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Method: DrawStopIcon*
PDF.DrawStopIcon(X As Integer,Y As Integer)
Note : DrawStopIcon IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Method: DrawLine
PDF.DrawLine(X1 as Integer,Y1 as Integer,X2 as Integer,Y2 as Integer )
Draws a line from X1, Y1 to X2, Y2 in the current color. The current color is set with the ForeColor property.
Method: DrawNoteIcon*
PDF.DrawNoteIcon(X As Integer,Y As Integer)
Note : DrawNoteIcon IS NOT CURRENTLY SUPPORTED, and is here for backward compatiblity.
Method: DrawRect
PDF.DrawRect(X1 as Integer,Y1 as Integer,Width as Integer,Height as Integer )
Draws the outline of a rectangle in the current color. The current color is set with the ForeColor property.
X and Y are the coordinates of the top-left corner. Width and Height specify the size of the rectangle.
Method: DrawRoundRect
PDF.DrawRoundRect(X1 as Integer,Y1 as Integer,Width as Integer,Height as Integer,ArcWidth as integer,ArcHeight as Integer)
Draws the outline of a rounded rectangle in the current color. The current color is set with the ForeColor property.
X and Y are the coordinates of the top-left corner. Width and Height specify the size of the round rectangle.
ArcWidth and ArcHeight control the shape of the corners in the horizontal and vertical axes, respectively. They are the distance (in points) from the corner at which the arc begins. Setting them to zero results in a rectangle with sharp corners.
Method: DrawObject
Need Documentation here
Method: DrawOval
PDF.Oval(X1 as Integer,Y1 as Integer,Width as Integer,Height as Integer)
Draws the outline of an oval in the current color. The current color is set with the ForeColor property.
X and Y are the coordinates of the top-left corner. Width and Height specify the size of the oval.
Method: DrawPicture
PDF.DrawPicture ( Image as Picture, X as Integer, Y as Integer [,DestWidth as Integer ] [, DestHeight as Integer ] [, SourceX as Integer ] [, SourceY as Integer ] [, SourceWidth as Integer ] [, SourceHeight as Integer] )
Draws the picture at the specified location. The picture can be shown at full size, cropped, or scaled. All units are points.
Refer to the Xojo™ documentation for more specific details on this command.
Method: DrawPolygon
Need Documentation here
Method: DrawString
Need Documentation here
Method: FillOval
PDF.FillOval(X1 as Integer,Y1 as Integer,Width as Integer,Height as Integer)
Draws an oval filled with the current color. The current color is set with the ForeColor property.
X and Y are the coordinates of the top-left corner. Width and Height specify the size of the oval.
Method: FillPolygon
Need Documentation here
Method: FillRect
PDF.FillRect(X1 as Integer,Y1 as Integer,Width as Integer,Height as Integer )
Draws a rectangle filled the current color. The current color is set with the ForeColor property.
X and Y are the coordinates of the top-left corner. Width and Height specify the size of the rectangle.
Method: FillRoundRect
Need Documentation here
Method: Margins
Need Documentation here
Method: NextPage
PDF.NextPage
this method will cause the current page to be printed and a new page to be created.
If used with nonPDF output, only the last page will be displayed.
Method: InitPicture
Need Documentation here
Method: Reuse
Need Documentation here
Method: Pattern
Need Documentation here
Method: Pixel*
Need Documentation here
Method: Output
Need Documentation here
Method: StringHeight
Need Documentation here
Method: StringWidth
Need Documentation here


Page Sizes and Margins


PDF MODE
GRAPHIC MODE



└─PageTop
 
├─Top
 
◄─Left─► ◄───Width───►





Height


















P
a
g
e
h
e
i
g
h
t












 
 
◄─PageLeft
◄─────────PageWidth─────────►