PDFGen Component

Properties   Methods   Events   Config Settings   Errors  

The PDFGen class creates PDF documents from scratch.

Syntax

pdfsdk.PDFGen

Remarks

PDFGen is a versatile document generation component that can be used to create PDF documents in a highly customizable way.

Preparing the document for editing is as easy as calling CreateNew. Before calling this method, optionally configure baseline properties that you would like to apply to the new document, such as its page dimensions (SetLayout), page numbering (SetDocumentProperty), or PDF/A compliance requirements (PDFAConformanceLevel). Then start composing the document by adding content. When finished, call Close to close the document and save the changes to either OutputFile or OutputData.

The example below configures page numbers in the right header, adds a centered title with bold and underline formatting, and finally adds a left-aligned paragraph. PDFGen pdfgen = new PDFGen(); pdfgen.OutputFile = "output.pdf"; pdfgen.SetDocumentProperty("PageRightHeader", "%PAGENUMBER%"); pdfgen.CreateNew(); pdfgen.SetAlignment((int)HorizontalAlignments.haCenter, (int)VerticalAlignments.vaTop); pdfgen.SetFont("Arial", "20", "bold underline", "forestgreen"); pdfgen.AddText("The Preface", false); pdfgen.SetFont("Times New Roman", "14", "regular", "black"); pdfgen.AddBreak(0, 2); pdfgen.SetAlignment((int)HorizontalAlignments.haLeft, (int)VerticalAlignments.vaTop); pdfgen.AddParagraph("The artist is the creator of beautiful things. To reveal art and conceal the artist is art's aim. The critic is he who can translate into another manner or a new material his impression of beautiful things."); pdfgen.Close();

Canvases and the Editing Process

Every editing operation performed by PDFGen goes through a canvas, which is an editing window with a set of rules and operations defined for it that is either:

  • A text canvas, which can be thought of as a multi-line rich text editor;
  • A drawing canvas, a rectangular random-access drawing area; or
  • A table canvas, a rectangular grid of rows and columns.

The canvas types are distinct, meaning only one of them can be used at a time to create a specific piece of content. Canvases of different types can be grouped together or used as part of other canvases, which provides a powerful and flexible tool for creating content of various types and complexities. For example, a drawing canvas containing a graphic can be embedded into a text canvas containing the document body.

When CreateNew is called, the component automatically creates a page-wide text canvas (a "page canvas") so you can start adding content right away. This canvas takes into account the dimensions of the page and any margins configured. One-inch margins are set by default. Upon reaching the end of the page, the component closes the corresponding canvas, creates a new one for the next page (thus "turning the page" behind the scenes), and continues until all the content has been added.

You can always create your own canvases (and sub-canvases) should you need to add non-standard kinds of content that go beyond the traditional document layout, such as marginal notes, watermarks, or signatures.

Additionally, a canvas exists in one of three states:

  • Open, where it is in the process of editing and the content can still be changed;
  • Closed, where editing has been completed and the content has been finalized ("committed"); or
  • Rendered, where the content has been serialized from its internal closed representation into a PDF graphics stream.
An open canvas resembles an active editing area. Examples include a text canvas containing a line of text to which words are still being added, and a drawing canvas containing a path that has been started but not completed.

Changes made to an open canvas may influence how the content is represented in the document when the canvas is eventually rendered. For example, any text added to a center-aligned line in a text canvas will cause existing text to move leftward. Any text added to a drawing canvas - which is random access and does not offer the capability of formatting - will not affect any other content added to it previously.

A closed canvas resembles an opaque rectangle filled with visual elements. Once a canvas is closed, all such elements become locked and their dimensions are known, which enables their absolute positions and sizes to be calculated unambiguously as the component can be certain that they will not change.

During the editing process, PDFGen creates pieces of content, fills them in, closes them, and renders them onto the page. It adds content to the document sequentially like a typewriter: once added, content cannot be deleted. However, unlike a typewriter, content can be automatically formatted by the component on a later stage. For example, updating the dimensions of a text canvas may cause elements added to it previously to be rearranged, similar to how expanding a text area control in a browser form rearranges its content.

Text Canvases

A text canvas is a vertical series of lines, each comprised of a horizontal series of elements. It is analogous to a traditional text editor and is used for creating structured (mostly textual) content, which is added element by element, line by line. Pages, signature fields added via AddSignatureField, and table cells are all kinds of text canvases.

Random access is not allowed in text canvases; instead, the component stacks elements in the current line and arranges them as they are added. This means that in general, the dimensions of a text canvas (its CanvasWidth and CanvasHeight) are not fixed and may expand horizontally and vertically.

If the current line is full and cannot accommodate a subsequent element (and the chosen constraints do not allow for it to be expanded), in most cases the component completes the current line, adds a new one, places the cursor at the beginning of the new line, and adds the element there. However, if the element's width exceeds CanvasMaxWidth, it will not fit in the new line either, so the OutOfSpace event fires to give your code a chance to forcefully expand the canvas or cancel the insertion of the element altogether.

Similarly, exceeding CanvasMaxHeight also causes the component to automatically wrap to the next default canvas (e.g., the next page or column) or trigger OutOfSpace. Subscribe to that event to recover from failed calls in a flexible way.

Drawing Canvases

A drawing canvas is analogous to a drawing board and is used for creating free-form vector content in two-dimensional Cartesian space. A drawing canvas provides random access: primitives can be placed anywhere within its bounds in any order, and all coordinates are specified relative to the bottom-left corner of the canvas.

Content is built from path primitives, which include lines, curves, and closed shapes that can be stroked, filled, or used to define clipping regions. Common shapes such as rectangles, circles, and polygons are also supported directly, as is importing SVG path data via AddDrawing and placing bitmaps via AddBitmap.

The visual appearance of each primitive is controlled by the active Pen and Brush at the time the path is started. The pen governs the stroke (color, thickness, style, line cap, and line join) and the brush governs the fill (color and opacity). Use SetPen and SetBrush to configure these properties; they remain in effect until changed.

The dimensions of a drawing canvas are fixed at creation time. Content that exceeds these bounds is clipped. When committed to its parent canvas via EndDrawing, the drawing canvas can be scaled, skewed, and rotated as needed.

When committed to a text canvas, a drawing canvas is treated as an inline element and flows with surrounding content, just like text and bitmaps. When committed to another drawing canvas, it is positioned at explicit coordinates within that canvas.

Table Canvases

A table canvas is used for creating grid-based content organized into rows and columns. The column count is fixed at creation time; rows and cells are added sequentially, and the layout engine resolves all column widths and row heights when the table is committed to its parent canvas via EndTable.

Each cell is itself a text canvas, so any content that can be added to a page can also be added to a cell, including paragraphs, bitmaps, and nested drawing canvases. Cells can span multiple columns or rows, which the layout engine automatically accounts for when distributing space.

Width constraints can be specified at both the table and cell level. When no preferred width is given, the layout engine distributes available space proportionally across columns based on their content. Row heights follow the same principle: the height of each row is determined by the tallest cell it contains, unless a fixed or minimum height is specified via StartTableRow.

The Pen and Brush active when a cell is opened determine its border style and background fill. Individual cell borders can be suppressed via a bitmask passed to StartTableCell, allowing any combination of top, right, bottom, and left borders to be hidden independently.

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AttachmentCountThe number of records in the Attachment arrays.
AttachmentAFRelationshipThe value of the AFRelationship key for the attachment, for example Alternative or Source .
AttachmentTypeThe type of the attachment.
AttachmentContentTypeThe content type of the attachment.
AttachmentCreationDateThe creation date of the attachment.
AttachmentDataThe raw data of the attachment.
AttachmentDescriptionA textual description of the attachment.
AttachmentFileNameThe path and filename of the attachment.
AttachmentModificationDateThe date and time of the file's last modification.
AttachmentNameThe name of the attachment.
AttachmentSizeThe attachment's size in bytes.
BrushColorThe fill color of the brush in hash-prefixed hexadecimal format or as a name.
BrushOpacityThe opacity of the brush fill, from 0 (fully transparent) to 1 (fully opaque).
CanvasTypeThe type of the canvas.
CanvasContentAnchorThis property is currently unsupported.
CanvasDrawingWhether the canvas is a random-access drawing canvas.
CanvasDrawingModeHow paths interact with the drawing canvas.
CanvasHeightThe current height of the canvas in points.
CanvasHorizontalAlignmentThe current horizontal alignment for text content in the text canvas.
CanvasMaxHeightThe maximum height of the canvas in points.
CanvasMaxWidthThe maximum width of the canvas in points.
CanvasMinHeightThe minimum height of the canvas in points.
CanvasMinWidthThe minimum width of the canvas in points.
CanvasVerticalAlignmentThe current vertical alignment for text content in the text canvas.
CanvasWidthThe current width of the canvas in points.
CanvasXThe X coordinate of the canvas in points.
CanvasYThe Y coordinate of the canvas in points.
FontColorThe color of the current font in hash-prefixed hexadecimal format or as a name.
FontNameThe name of the current font.
FontPathThe full file path to the current font, for example C:\\Windows\\Fonts\\times.
FontSizeThe size of the current font in points.
FontStyleThe style of the current font.
LayoutColCountThe number of columns on the page.
LayoutContentAnchorThis property is currently unsupported.
LayoutHeightThe height of the page in points.
LayoutSizeThe size of the page.
LayoutWidthThe width of the page in points.
OutputDataA byte array containing the PDF document after processing.
OutputFileThe path to a local file where the output is written.
OverwriteWhether the class should overwrite files.
PDFAConformanceLevelThe PDF/A conformance level of the document.
PenColorThe stroke color of the pen in hash-prefixed hexadecimal format or as a name.
PenOpacityThe opacity of the pen stroke, from 0 (fully transparent) to 1 (fully opaque).
PenStyleThe style of the pen.
PenThicknessThe line width of the pen stroke in points.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

AddAttachmentAdds an attachment to the document.
AddBitmapAdds a bitmap image to the current canvas.
AddBreakAdds a number of breaks to the text canvas.
AddButtonAdds a button field to the form.
AddCheckBoxAdds a checkbox field to the form.
AddComboBoxAdds a combo box field to the form.
AddCopyAdds a copy of a previously saved element to the current canvas.
AddDrawingAdds a vector drawing described by an SVG path string to the current canvas.
AddHeadingAdds a heading to the text canvas.
AddLinkAdds a hyperlink to the current canvas.
AddListBoxAdds a list box field to the form.
AddListItemAdds an item to a list, combo box, or list box.
AddParagraphAdds a paragraph of text to the text canvas.
AddRadioButtonAdds a radio button to the form.
AddSignatureFieldAdds a signature field to the form.
AddSpecialAdds a special element to the text canvas.
AddTableCellAdds a single-paragraph cell to the current table row.
AddTextAdds a piece of text to the current canvas.
AddTextBoxAdds a text box field to the form.
AddTitleAdds a title to the text canvas.
CancelCancels the current canvas.
CloseCloses the new document.
ConfigSets or retrieves a configuration setting.
CreateNewCreates a new PDF document.
DrawCircleDraws an ellipse or circle on the drawing canvas.
DrawCurveToAdds a cubic Bezier curve segment to the current path.
DrawLineToAdds a straight line segment to the current path.
DrawPolygonDraws a polygon on the drawing canvas.
DrawRectangleDraws a rectangle on the drawing canvas.
EndComboBoxCompletes the combo box field.
EndContentCompletes the logical section.
EndDrawingFinalizes the drawing canvas and commits it to the parent canvas.
EndEditingFinalizes the text canvas and commits it to the parent canvas.
EndFormCompletes and closes the current interactive form.
EndListCompletes the list.
EndListBoxCompletes the list box field.
EndListItemCompletes the list item.
EndParagraphCompletes the paragraph.
EndPathCompletes the current path and applies it to the drawing canvas.
EndSignatureFieldCompletes the signature field.
EndTableFinalizes the table canvas and commits it to the parent canvas.
EndTableCellCompletes the current table cell.
EndTableRowCompletes the current table row.
GetDocumentPropertyReturns the value of a document property.
GetFieldPropertyReturns the value of a field property.
GetPagePropertyReturns the value of a page property.
MoveToSets the current pen position on the drawing canvas.
RemoveAttachmentRemoves an attachment from the document.
ResetResets the class.
SaveStyleSaves the currently configured font, pen, and brush as a named style.
ScrollInserts a vertical gap into the text canvas.
SetAlignmentSets the alignment for subsequent text insertion operations.
SetBrushSets the fill properties used when drawing shapes and cell backgrounds.
SetDocumentPropertySets the value of a document property.
SetFieldPropertySets the value of a field property.
SetFontSets the font properties to be applied to text.
SetLayoutSets the layout for new pages.
SetMarginSets the margin for a typical element.
SetPagePropertySets the value of a page property.
SetPenSets the stroke properties used when drawing lines, paths, and borders.
SetStyleApplies a previously saved style or one of the built-in styles.
StartComboBoxBegins a new combo box field for editing.
StartContentBegins a new logical section.
StartDrawingInitiates a new drawing canvas of the given dimensions.
StartEditingInitiates a new text canvas for editing.
StartFormBegins a new form.
StartListBegins a new list for editing.
StartListBoxBegins a new list box field for editing.
StartListItemBegins a new list item for editing.
StartParagraphBegins a new paragraph for editing.
StartPathStarts a new vector path on the drawing canvas.
StartSignatureFieldBegins a new signature field for editing.
StartTableInitiates a new table canvas with a fixed number of columns.
StartTableCellBegins a new cell in the current table row.
StartTableRowBegins a new row in the current table.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ActionRequiredFired when the class encounters a conflict that it cannot resolve on its own.
EditingCompletedFired after a canvas has been closed.
ErrorFired when information is available about errors during data delivery.
FontLookupFired when a required font is missing.
LogFired once for each log message.
OutOfSpaceFired when an element exceeds the maximum dimensions of the current text canvas.

Config Settings


The following is a list of config settings for the component with short descriptions. Click on the links for further details.

AutoTurnPagesWhether to change the page automatically upon exceeding the lower page boundary.
CompressStreamsWhether to compress stream objects.
FallbackFontThe fallback font.
FontPathsThe font search paths.
FontPolicyThe font policy to follow.
LogLevelThe level of detail that is logged.
SaveChangesWhether to save changes made to the document.
SystemFontNamesThe system font names.
TempPathThe location where temporary files are stored.
UsedFontsThe fonts used in the document.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
MaskSensitiveDataWhether sensitive data is masked in log messages.
UseInternalSecurityAPIWhether or not to use the system security libraries or an internal implementation.

AttachmentCount Property (PDFGen Component)

The number of records in the Attachment arrays.

Syntax

func (obj *PDFGen) AttachmentCount() (int32, error)
func (obj *PDFGen) SetAttachmentCount(value int32) error

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at AttachmentCount - 1.

Data Type

int32

AttachmentAFRelationship Property (PDFGen Component)

The value of the AFRelationship key for the attachment, for example Alternative or Source .

Syntax

func (obj *PDFGen) AttachmentAFRelationship(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentAFRelationship(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The value of the AFRelationship key for the attachment, for example Alternative or Source.

This key in the file specification dictionary expresses the relationship between the attachment and the document, and it must be set for each attachment added to PDF/A-3 documents.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentType Property (PDFGen Component)

The type of the attachment.

Syntax

func (obj *PDFGen) AttachmentType(AttachmentIndex int32) (int32, error)

Possible Values

0   // Generic
1 // ElectronicInvoice

Default Value

0

Remarks

The type of the attachment.

Possible values are:

0 (patGeneric - default) A generic attachment.
1 (patElectronicInvoice) An XML invoice, for example in ZUGFeRD or Factur-X format.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

This property is read-only.

Data Type

int32

AttachmentContentType Property (PDFGen Component)

The content type of the attachment.

Syntax

func (obj *PDFGen) AttachmentContentType(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentContentType(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The content type of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentCreationDate Property (PDFGen Component)

The creation date of the attachment.

Syntax

func (obj *PDFGen) AttachmentCreationDate(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentCreationDate(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The creation date of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentData Property (PDFGen Component)

The raw data of the attachment.

Syntax

func (obj *PDFGen) AttachmentData(AttachmentIndex int32) ([]byte, error)
func (obj *PDFGen) SetAttachmentData(AttachmentIndex int32, value []byte) error

Default Value

""

Remarks

The raw data of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

[]byte

AttachmentDescription Property (PDFGen Component)

A textual description of the attachment.

Syntax

func (obj *PDFGen) AttachmentDescription(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentDescription(AttachmentIndex int32, value string) error

Default Value

""

Remarks

A textual description of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentFileName Property (PDFGen Component)

The path and filename of the attachment.

Syntax

func (obj *PDFGen) AttachmentFileName(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentFileName(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The path and filename of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentModificationDate Property (PDFGen Component)

The date and time of the file's last modification.

Syntax

func (obj *PDFGen) AttachmentModificationDate(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentModificationDate(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The date and time of the file's last modification.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentName Property (PDFGen Component)

The name of the attachment.

Syntax

func (obj *PDFGen) AttachmentName(AttachmentIndex int32) (string, error)
func (obj *PDFGen) SetAttachmentName(AttachmentIndex int32, value string) error

Default Value

""

Remarks

The name of the attachment.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

Data Type

string

AttachmentSize Property (PDFGen Component)

The attachment's size in bytes.

Syntax

func (obj *PDFGen) AttachmentSize(AttachmentIndex int32) (int64, error)

Default Value

0

Remarks

The attachment's size in bytes.

The AttachmentIndex parameter specifies the index of the item in the array. The size of the array is controlled by the AttachmentCount property.

This property is read-only.

Data Type

int64

BrushColor Property (PDFGen Component)

The fill color of the brush in hash-prefixed hexadecimal format or as a name.

Syntax

func (obj *PDFGen) BrushColor() (string, error)

Default Value

"#FFFFFF"

Remarks

The fill color of the brush in hash-prefixed hexadecimal format or as a name.

Note that a brush with the default color will not produce a visible fill until it has been explicitly activated via SetBrush.

This property is read-only.

Data Type

string

BrushOpacity Property (PDFGen Component)

The opacity of the brush fill, from 0 (fully transparent) to 1 (fully opaque).

Syntax

func (obj *PDFGen) BrushOpacity() (string, error)

Default Value

""

Remarks

The opacity of the brush fill, from 0 (fully transparent) to 1 (fully opaque).

This property is read-only.

Data Type

string

CanvasType Property (PDFGen Component)

The type of the canvas.

Syntax

func (obj *PDFGen) CanvasType() (int32, error)

Possible Values

0   // Page
1 // Text
2 // Drawing
3 // Table
4 // TableCell
5 // SignatureField

Default Value

0

Remarks

The type of the canvas.

Possible values are:

0 (ctPage - default)
1 (ctText)
2 (ctDrawing)
3 (ctTable)
4 (ctTableCell)
5 (ctSignatureField)

This property is also available as a parameter of the EditingCompleted event.

This property is read-only.

Data Type

int32

CanvasContentAnchor Property (PDFGen Component)

This property is currently unsupported.

Syntax

func (obj *PDFGen) CanvasContentAnchor() (int32, error)

Possible Values

0   // Top
1 // Center
2 // Bottom

Default Value

0

Remarks

This property is currently unsupported.

This property is read-only.

Data Type

int32

CanvasDrawing Property (PDFGen Component)

Whether the canvas is a random-access drawing canvas.

Syntax

func (obj *PDFGen) CanvasDrawing() (bool, error)

Default Value

false

Remarks

Whether the canvas is a random-access drawing canvas.

This property is read-only.

Data Type

bool

CanvasDrawingMode Property (PDFGen Component)

How paths interact with the drawing canvas.

Syntax

func (obj *PDFGen) CanvasDrawingMode() (int32, error)

Possible Values

0   // Drawing
1 // Clipping
2 // Mask

Default Value

0

Remarks

How paths interact with the drawing canvas.

Possible values are:

0 (dmDrawing) The path is rendered as a filled and/or stroked shape.
1 (dmClipping) The path defines a clipping region; subsequent drawing is masked to the interior of this path.
2 (dmMask) Reserved for future use.

This property is read-only.

Data Type

int32

CanvasHeight Property (PDFGen Component)

The current height of the canvas in points.

Syntax

func (obj *PDFGen) CanvasHeight() (string, error)

Default Value

"0"

Remarks

The current height of the canvas in points.

This property is also available as a parameter of the EditingCompleted event.

This property is read-only.

Data Type

string

CanvasHorizontalAlignment Property (PDFGen Component)

The current horizontal alignment for text content in the text canvas.

Syntax

func (obj *PDFGen) CanvasHorizontalAlignment() (int32, error)

Possible Values

0   // Left
1 // Center
2 // Right
3 // Justify

Default Value

0

Remarks

The current horizontal alignment for text content in the text canvas.

Possible values are:

0 (haLeft - default)
1 (haCenter)
2 (haRight)
3 (haJustify)

This property is read-only.

Data Type

int32

CanvasMaxHeight Property (PDFGen Component)

The maximum height of the canvas in points.

Syntax

func (obj *PDFGen) CanvasMaxHeight() (string, error)
func (obj *PDFGen) SetCanvasMaxHeight(value string) error

Default Value

"0"

Remarks

The maximum height of the canvas in points. Both integer and decimal values are supported.

Data Type

string

CanvasMaxWidth Property (PDFGen Component)

The maximum width of the canvas in points.

Syntax

func (obj *PDFGen) CanvasMaxWidth() (string, error)
func (obj *PDFGen) SetCanvasMaxWidth(value string) error

Default Value

"0"

Remarks

The maximum width of the canvas in points. Both integer and decimal values are supported.

Data Type

string

CanvasMinHeight Property (PDFGen Component)

The minimum height of the canvas in points.

Syntax

func (obj *PDFGen) CanvasMinHeight() (string, error)

Default Value

"0"

Remarks

The minimum height of the canvas in points.

This property is read-only.

Data Type

string

CanvasMinWidth Property (PDFGen Component)

The minimum width of the canvas in points.

Syntax

func (obj *PDFGen) CanvasMinWidth() (string, error)

Default Value

"0"

Remarks

The minimum width of the canvas in points.

This property is read-only.

Data Type

string

CanvasVerticalAlignment Property (PDFGen Component)

The current vertical alignment for text content in the text canvas.

Syntax

func (obj *PDFGen) CanvasVerticalAlignment() (int32, error)

Possible Values

0   // Top
1 // Center
2 // Bottom

Default Value

0

Remarks

The current vertical alignment for text content in the text canvas.

Possible values are:

0 (vaTop - default)
1 (vaCenter)
2 (vaBottom)

This property is read-only.

Data Type

int32

CanvasWidth Property (PDFGen Component)

The current width of the canvas in points.

Syntax

func (obj *PDFGen) CanvasWidth() (string, error)

Default Value

"0"

Remarks

The current width of the canvas in points.

This property is also available as a parameter of the EditingCompleted event.

This property is read-only.

Data Type

string

CanvasX Property (PDFGen Component)

The X coordinate of the canvas in points.

Syntax

func (obj *PDFGen) CanvasX() (string, error)

Default Value

"0"

Remarks

The X coordinate of the canvas in points.

This property is also available as a parameter of the EditingCompleted event.

This property is read-only.

Data Type

string

CanvasY Property (PDFGen Component)

The Y coordinate of the canvas in points.

Syntax

func (obj *PDFGen) CanvasY() (string, error)

Default Value

"0"

Remarks

The Y coordinate of the canvas in points.

This property is also available as a parameter of the EditingCompleted event.

This property is read-only.

Data Type

string

FontColor Property (PDFGen Component)

The color of the current font in hash-prefixed hexadecimal format or as a name.

Syntax

func (obj *PDFGen) FontColor() (string, error)

Default Value

"#000000"

Remarks

The color of the current font in hash-prefixed hexadecimal format or as a name.

This property is read-only.

Data Type

string

FontName Property (PDFGen Component)

The name of the current font.

Syntax

func (obj *PDFGen) FontName() (string, error)

Default Value

"Times New Roman"

Remarks

The name of the current font.

This property is read-only.

Data Type

string

FontPath Property (PDFGen Component)

The full file path to the current font, for example C:\\Windows\\Fonts\\times.

Syntax

func (obj *PDFGen) FontPath() (string, error)

Default Value

""

Remarks

The full file path to the current font, for example C:\Windows\Fonts\times.ttf.

This property returns an empty string if a built-in font is in use.

This property is read-only.

Data Type

string

FontSize Property (PDFGen Component)

The size of the current font in points.

Syntax

func (obj *PDFGen) FontSize() (string, error)

Default Value

"12"

Remarks

The size of the current font in points.

This property is read-only.

Data Type

string

FontStyle Property (PDFGen Component)

The style of the current font.

Syntax

func (obj *PDFGen) FontStyle() (string, error)

Default Value

""

Remarks

The style of the current font.

This property is read-only.

Data Type

string

LayoutColCount Property (PDFGen Component)

The number of columns on the page.

Syntax

func (obj *PDFGen) LayoutColCount() (int32, error)

Default Value

1

Remarks

The number of columns on the page.

This property is read-only.

Data Type

int32

LayoutContentAnchor Property (PDFGen Component)

This property is currently unsupported.

Syntax

func (obj *PDFGen) LayoutContentAnchor() (int32, error)

Possible Values

0   // Top
1 // Center
2 // Bottom

Default Value

0

Remarks

This property is currently unsupported.

This property is read-only.

Data Type

int32

LayoutHeight Property (PDFGen Component)

The height of the page in points.

Syntax

func (obj *PDFGen) LayoutHeight() (string, error)

Default Value

"792"

Remarks

The height of the page in points.

This property is read-only.

Data Type

string

LayoutSize Property (PDFGen Component)

The size of the page.

Syntax

func (obj *PDFGen) LayoutSize() (string, error)

Default Value

""

Remarks

The size of the page. Please see SetLayout for more details.

This property is read-only.

Data Type

string

LayoutWidth Property (PDFGen Component)

The width of the page in points.

Syntax

func (obj *PDFGen) LayoutWidth() (string, error)

Default Value

"612"

Remarks

The width of the page in points.

This property is read-only.

Data Type

string

OutputData Property (PDFGen Component)

A byte array containing the PDF document after processing.

Syntax

func (obj *PDFGen) OutputData() ([]byte, error)

Remarks

This property is used to read the byte array containing the produced output after the operation has completed. It is only set if an output file has not been assigned via OutputFile.

This property is read-only.

Data Type

[]byte

OutputFile Property (PDFGen Component)

The path to a local file where the output is written.

Syntax

func (obj *PDFGen) OutputFile() (string, error)
func (obj *PDFGen) SetOutputFile(value string) error

Default Value

""

Remarks

This property is used to provide a path where the resulting PDF document is saved after the operation has completed.

Data Type

string

Overwrite Property (PDFGen Component)

Whether the class should overwrite files.

Syntax

func (obj *PDFGen) Overwrite() (bool, error)
func (obj *PDFGen) SetOverwrite(value bool) error

Default Value

false

Remarks

This property indicates whether the component overwrites OutputFile. If set to false, an error is thrown whenever OutputFile exists before an operation.

Data Type

bool

PDFAConformanceLevel Property (PDFGen Component)

The PDF/A conformance level of the document.

Syntax

func (obj *PDFGen) PDFAConformanceLevel() (int32, error)
func (obj *PDFGen) SetPDFAConformanceLevel(value int32) error

Possible Values

0   // None
1 // A1a
2 // A1b
3 // A2a
4 // A2b
5 // A2u
6 // A3a
7 // A3b
8 // A3u
9 // A4
10 // A4e
11 // A4f

Default Value

0

Remarks

This property is used to specify the desired PDF/A conformance level the component attempts to apply when operating on the document.

Possible values are:

0 (paclNone - default) No PDF/A compliance
1 (paclA1a) PDF/A-1a
2 (paclA1b) PDF/A-1b
3 (paclA2a) PDF/A-2a
4 (paclA2b) PDF/A-2b
5 (paclA2u) PDF/A-2u
6 (paclA3a) PDF/A-3a
7 (paclA3b) PDF/A-3b
8 (paclA3u) PDF/A-3u
9 (paclA4) PDF/A-4
10 (paclA4e) PDF/A-4e
11 (paclA4f) PDF/A-4f

Data Type

int32

PenColor Property (PDFGen Component)

The stroke color of the pen in hash-prefixed hexadecimal format or as a name.

Syntax

func (obj *PDFGen) PenColor() (string, error)

Default Value

"#000000"

Remarks

The stroke color of the pen in hash-prefixed hexadecimal format or as a name.

This property is read-only.

Data Type

string

PenOpacity Property (PDFGen Component)

The opacity of the pen stroke, from 0 (fully transparent) to 1 (fully opaque).

Syntax

func (obj *PDFGen) PenOpacity() (string, error)

Default Value

""

Remarks

The opacity of the pen stroke, from 0 (fully transparent) to 1 (fully opaque).

This property is read-only.

Data Type

string

PenStyle Property (PDFGen Component)

The style of the pen.

Syntax

func (obj *PDFGen) PenStyle() (string, error)

Default Value

""

Remarks

The style of the pen.

This property is read-only.

Data Type

string

PenThickness Property (PDFGen Component)

The line width of the pen stroke in points.

Syntax

func (obj *PDFGen) PenThickness() (string, error)

Default Value

""

Remarks

The line width of the pen stroke in points.

This property is read-only.

Data Type

string

AddAttachment Method (PDFGen Component)

Adds an attachment to the document.

Syntax

func (obj *PDFGen) AddAttachment(FileName string, Description string, AttachmentType int32) error

Remarks

This method is used to add an attachment (embedded file) to the document and to the Attachment* properties.

FileName and Description specify the filename and description of the attachment respectively.

AttachmentType specifies the type of the attachment. Possible values are:

0 (patGeneric - default) A generic attachment.
1 (patElectronicInvoice) An XML invoice, for example in ZUGFeRD or Factur-X format.

Example: pdfgen.AddAttachment("foo.txt", "desc", (int)PDFAttachmentTypes.patGeneric); // Alternatively, create a PDFAttachment object and add it to Attachments manually: PDFAttachment attachment = new PDFAttachment(); attachment.FileName = "foo.txt"; // or attachment.DataB = new byte[] { ... }; attachment.Description = "desc"; pdfgen.Attachments.Add(attachment); // Or using one of the constructors: pdfgen.Attachments.Add(new PDFAttachment("foo.txt", "desc")); pdfgen.Close(); The full list of attachments is contained in the Attachment* properties.

AddBitmap Method (PDFGen Component)

Adds a bitmap image to the current canvas.

Syntax

func (obj *PDFGen) AddBitmap(Format string, Bytes []byte, BitmapWidth int32, BitmapHeight int32, ScaleWidth string, ScaleHeight string) error

Remarks

This method is used to add a bitmap image to the current canvas.

Its behavior differs depending on the type of canvas it is called on. On a text canvas, the image is treated as an inline element and placed in the normal flow of content, following the same layout rules as text and other content. On a drawing canvas, the image is placed at the current pen position as set by MoveTo.

Format specifies the image format and color space of the supplied bytes, as a combined string (e.g., png-rgb, jpeg-cmyk).

Bytes contains the raw image data.

BitmapWidth and BitmapHeight specify the intrinsic pixel dimensions of the image.

ScaleWidth and ScaleHeight specify the rendered dimensions of the image. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

NOTE: This method throws an exception if a list is currently being edited.

AddBreak Method (PDFGen Component)

Adds a number of breaks to the text canvas.

Syntax

func (obj *PDFGen) AddBreak(BreakKind int32, Count int32) error

Remarks

This method is used to add Count breaks to the current text canvas, completing the current line, column, or page early and starting a new one (or multiple).

BreakKind specifies the kind of break to add. Possible values are:

0 (bkLine) A line break.
1 (bkColumn) Currently unsupported.
2 (bkPage) A page break.

NOTE: This method throws an exception if the current canvas is not a text canvas.

AddButton Method (PDFGen Component)

Adds a button field to the form.

Syntax

func (obj *PDFGen) AddButton(FieldName string, Caption string, ActionType int32, Width string, Height string) error

Remarks

This method is used to create a button field with name FieldName and caption Caption.

ActionType specifies the type of action that is executed when the button is pressed. Possible values are:

0 (batNone) No action
1 (batSubmit) Submit-form action
2 (batReset) Reset-form action
3 (batImport) Import-data action

Width and Height specify the width and height of the button. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddCheckBox Method (PDFGen Component)

Adds a checkbox field to the form.

Syntax

func (obj *PDFGen) AddCheckBox(FieldName string, DefaultValue bool, Width string, Height string) error

Remarks

This method is used to create a checkbox field with name FieldName.

DefaultValue specifies the initial state of the checkbox (checked/unchecked).

Width and Height specify the width and height of the checkbox. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddComboBox Method (PDFGen Component)

Adds a combo box field to the form.

Syntax

func (obj *PDFGen) AddComboBox(FieldName string, Options string, DefaultValue string, Width string, Height string) error

Remarks

This method is used to create a combo box field with name FieldName.

Options specifies a list of choices as a multi-line string.

DefaultValue specifies the initial value selected in the combo box.

Width and Height specify the width and height of the combo box. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

To create a combo box incrementally instead of all at once, use StartComboBox and EndComboBox.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddCopy Method (PDFGen Component)

Adds a copy of a previously saved element to the current canvas.

Syntax

func (obj *PDFGen) AddCopy(Id string, ScaleX string, ScaleY string, Rotation string, SkewA string, SkewB string) error

Remarks

This method is used to add a copy of an element that was previously saved in the component to the current canvas.

Id specifies the Id given to the saved:

  • Canvas when it was closed in one of the canvas-finalizing End* methods
  • Path when it was completed in EndPath
  • List when it was completed in EndList
  • Paragraph when it was completed in EndParagraph
  • Table row when it was closed in EndTableRow

A saved element may be added any number of times, to any number of canvases.

On a text canvas, the copy is treated as an inline element and placed in the normal flow of content, following the same layout rules as text and other content. On a drawing canvas, the copy is placed at the current pen position as set by MoveTo.

Note that a saved path can only be added to a drawing canvas; attempting to add one to any other type of canvas throws an exception.

ScaleX and ScaleY specify the horizontal and vertical scale factors to apply to the copy when placing it on the current canvas, with 1.0 being the original size of the saved element (100%).

Rotation specifies the rotation angle of the copy in degrees counterclockwise. If empty or 0, no rotation is applied.

SkewA and SkewB specify the horizontal and vertical skew angles of the copy in degrees. SkewA shears along the X axis and SkewB shears along the Y axis. If empty or 0, no skew is applied.

NOTE: This method throws an exception if a list is currently being edited.

AddDrawing Method (PDFGen Component)

Adds a vector drawing described by an SVG path string to the current canvas.

Syntax

func (obj *PDFGen) AddDrawing(SvgPath string, ScaleX string, ScaleY string) error

Remarks

This method is used to parse an SVG path data string and add the resulting drawing to the current canvas.

SvgPath is a standard SVG path data string using the commands M, L, H, V, C, S, Q, T, A, Z (and their lowercase relative equivalents). The following commands are supported:

M / m Move to (absolute / relative)
L / l Line to
H / h Horizontal line to
V / v Vertical line to
C / c Cubic Bezier curve
S / s Smooth cubic Bezier curve
Q / q Quadratic Bezier curve
T / t Smooth quadratic Bezier curve
A / a Elliptical arc
Z / z Close path

ScaleX and ScaleY specify the horizontal and vertical scale factors to apply to the drawing when placing it on the parent canvas. These parameters accept real values, with 1.0 being the actual size of the drawing (100%).

If the current canvas is already a drawing canvas, the path is imported directly into it. Otherwise, a temporary drawing canvas is created, the path is added to it, and the canvas is committed to the current canvas using ScaleX and ScaleY.

NOTE: This method throws an exception if a list is currently being edited.

AddHeading Method (PDFGen Component)

Adds a heading to the text canvas.

Syntax

func (obj *PDFGen) AddHeading(Level int32, Text string) error

Remarks

This method is currently unsupported.

AddLink Method (PDFGen Component)

Adds a hyperlink to the current canvas.

func (obj *PDFGen) AddLink(Text string, URL string) error

This method is used to add a clickable hyperlink to the current canvas whose visible label is Text. Clicking the link opens the external URL specified by URL.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddListBox Method (PDFGen Component)

Adds a list box field to the form.

Syntax

func (obj *PDFGen) AddListBox(FieldName string, Options string, DefaultValue string, Width string, Height string) error

Remarks

This method is used to create a list box field with name FieldName.

Options specifies a list of choices as a multi-line string.

DefaultValue specifies the initial value selected in the list box.

Width and Height specify the width and height of the list box. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

To create a list box incrementally instead of all at once, use StartListBox and EndListBox.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddListItem Method (PDFGen Component)

Adds an item to a list, combo box, or list box.

Syntax

func (obj *PDFGen) AddListItem(Text string) error

Remarks

This method is used to add Text as either a list item or a choice in a combo box or list box field.

When this method is used to add a choice to a form field, Text can either contain a user-readable value alone, or be followed by an internal (exported) name that is recorded as the value of the field if the option is selected. If provided, the internal name must be separated from the preceding user-readable value by the vertical bar character (|). If the internal name postfix is omitted, the user-readable value is recorded as the field value if the option is selected.

Example: // The value displayed to the user is "Pineapple", and the exported value is "pineapple" pdfgen.AddListItem("Pineapple|pineapple"); // The exported value of the option matches the value displayed to the user ("Olives") pdfgen.AddListItem("Olives"); // The value displayed to the user is "Roasted Marshmallows", and the exported value is "marshmallows" pdfgen.AddListItem("Roasted Marshmallows|marshmallows"); To create a list item incrementally instead of all at once, use StartListItem and EndListItem.

NOTE: This method throws an exception if the current canvas is not a text canvas.

NOTE: If used to add a list item, this method throws an exception if a list is not currently being edited.

AddParagraph Method (PDFGen Component)

Adds a paragraph of text to the text canvas.

Syntax

func (obj *PDFGen) AddParagraph(Text string) error

Remarks

This method is used to add a paragraph of Text to the current text canvas, which is done by breaking the text into lines and then words, and adding each word as a separate piece of text. When the end of a line is reached, the component inserts a line break and applies the line spacing set in SetMargin before continuing on to the next line of the paragraph.

Use SetAlignment and SetFont to adjust the parameters of the text that comprises the new paragraph, and use SetMargin to indent the first line of the paragraph.

To create a paragraph incrementally instead of all at once, use StartParagraph and EndParagraph.

NOTE: If Text is empty, a line break is added.

NOTE: This method throws an exception if the current canvas is not a text canvas or if a list is currently being edited.

AddRadioButton Method (PDFGen Component)

Adds a radio button to the form.

Syntax

func (obj *PDFGen) AddRadioButton(FieldName string, RadioGroup string, IsDefaultButton bool, Width string, Height string) error

Remarks

This method is used to create a radio button field with name FieldName within the radio group RadioGroup.

IsDefaultButton specifies whether the radio button will be selected initially (i.e., whether it will be the default value of the radio group).

Width and Height specify the width and height of the radio button. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddSignatureField Method (PDFGen Component)

Adds a signature field to the form.

Syntax

func (obj *PDFGen) AddSignatureField(FieldName string, Width string, Height string) error

Remarks

This method is used to create a signature field with name FieldName as a text canvas.

Width and Height specify the width and height of the signature field. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

To create a signature field incrementally instead of all at once, use StartSignatureField and EndSignatureField.

NOTE: This method only applies if the current canvas is a text canvas.

NOTE: This method throws an exception if a list is currently being edited.

AddSpecial Method (PDFGen Component)

Adds a special element to the text canvas.

Syntax

func (obj *PDFGen) AddSpecial(ObjectType int32, Content string) error

Remarks

This method is currently unsupported.

AddTableCell Method (PDFGen Component)

Adds a single-paragraph cell to the current table row.

Syntax

func (obj *PDFGen) AddTableCell(Text string, Width string) error

Remarks

This convenience method is used to open a new cell, add Text as a paragraph, and close the cell in a single call. It is equivalent to calling StartTableCell with ColSpan and RowSpan set to 1 and Borders set to 0, followed by AddParagraph and EndTableCell.

Text specifies the text content of the cell. If empty, an empty cell is added.

Width specifies the cell width constraints using the same [preferred]:[min]:[max] syntax as the corresponding parameter in StartTableCell. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Use this method when a cell contains only a single plain-text paragraph and does not require colspan, rowspan, or complex inner content. For cells with richer content or spanning requirements, use StartTableCell and EndTableCell directly.

NOTE: This method throws an exception if the current canvas is not a table canvas.

AddText Method (PDFGen Component)

Adds a piece of text to the current canvas.

Syntax

func (obj *PDFGen) AddText(Text string, Wrappable bool) error

Remarks

This method is used to add a piece of Text to the current canvas. Use SetAlignment and SetFont to adjust new text parameters.

Wrappable is reserved for future use.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddTextBox Method (PDFGen Component)

Adds a text box field to the form.

Syntax

func (obj *PDFGen) AddTextBox(FieldName string, DefaultValue string, MultiLine bool, Password bool, Width string, Height string) error

Remarks

This method is used to create a text box field with name FieldName.

DefaultValue specifies the initial value contained in the text box.

MultiLine specifies whether the text box can contain multiple lines of text.

Password specifies whether the text box is intended to contain a password. Pass true to have the text displayed as asterisk characters (*).

Width and Height specify the width and height of the text box. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

AddTitle Method (PDFGen Component)

Adds a title to the text canvas.

Syntax

func (obj *PDFGen) AddTitle(Text string) error

Remarks

This method is currently unsupported.

Cancel Method (PDFGen Component)

Cancels the current canvas.

Syntax

func (obj *PDFGen) Cancel() error

Remarks

This method is used to cancel the canvas that is currently being edited. It should be called after one of the following methods as an alternative to setting Choice to oscFullCancel within the OutOfSpace event:

Example: pdfgen.StartEditing("100", "100", (int)ContentAnchors.caTop); pdfgen.AddText("Hello world!", false); try { pdfgen.EndEditing("1", "1", "0", "0", "0", ""); } catch (PDFSDKException ex) { pdfgen.Cancel(); } NOTE: This method throws an exception if the current canvas is a page canvas.

Close Method (PDFGen Component)

Closes the new document.

Syntax

func (obj *PDFGen) Close() error

Remarks

This method is used to close the new document. It should always be preceded by a call to CreateNew.

Example: pdfgen.OutputFile = "output.pdf"; pdfgen.CreateNew(); // Some operation pdfgen.Close(); The document is saved automatically to OutputFile or OutputData when this method is called. To configure this saving behavior, set SaveChanges.

Config Method (PDFGen Component)

Sets or retrieves a configuration setting.

Syntax

func (obj *PDFGen) Config(ConfigurationString string) (string, error)

Remarks

Config is a generic method available in every component. It is used to set and retrieve configuration settings for the component.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

CreateNew Method (PDFGen Component)

Creates a new PDF document.

Syntax

func (obj *PDFGen) CreateNew() error

Remarks

This method is used to create a blank PDF document with one empty page and an underlying page canvas. Use SetLayout to adjust the new page dimensions and number of columns. Having created the baseline document, use the component's methods to add objects to it.

Upon completion of this method, information about the newly created page canvas can be accessed using the Canvas property.

DrawCircle Method (PDFGen Component)

Draws an ellipse or circle on the drawing canvas.

Syntax

func (obj *PDFGen) DrawCircle(RadiusX string, RadiusY string) error

Remarks

This method is used to add a closed elliptical shape to the current drawing canvas, centered at the current pen position as set by MoveTo.

RadiusX and RadiusY specify the horizontal and vertical radii of the ellipse. To draw a perfect circle, pass equal values for both. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Use SetPen and SetBrush before calling this method to control the border style and fill color.

NOTE: This method throws an exception if the current canvas is not a drawing canvas.

DrawCurveTo Method (PDFGen Component)

Adds a cubic Bezier curve segment to the current path.

Syntax

func (obj *PDFGen) DrawCurveTo(X string, Y string, ViaX1 string, ViaY1 string, ViaX2 string, ViaY2 string) error

Remarks

This method is used to extend the currently open path on the drawing canvas with a cubic Bezier curve from the current pen position to the endpoint specified by X and Y. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

ViaX1 and ViaY1 specify the first control point, which influences the curve near its start.

ViaX2 and ViaY2 specify the second control point, which influences the curve near its end.

Upon completion of this method, the current pen position will be moved to (X, Y).

NOTE: This method throws an exception if the current canvas is not a drawing canvas or if no path has been started with StartPath.

DrawLineTo Method (PDFGen Component)

Adds a straight line segment to the current path.

Syntax

func (obj *PDFGen) DrawLineTo(X string, Y string) error

Remarks

This method is used to extend the currently open path on the drawing canvas with a straight line from the current pen position to the point specified by X and Y. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Upon completion of this method, the current pen position will be moved to (X, Y).

NOTE: This method throws an exception if the current canvas is not a drawing canvas or if no path has been started with StartPath.

DrawPolygon Method (PDFGen Component)

Draws a polygon on the drawing canvas.

Syntax

func (obj *PDFGen) DrawPolygon(Points string) error

Remarks

This method is used to add a closed polygon defined by a list of vertices to the current drawing canvas.

Points specifies a comma-separated list of coordinate pairs in the form X1,Y1,X2,Y2,...,XN,YN containing at least three vertices. All coordinates are relative to the bottom-left corner of the drawing canvas. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

The first vertex is used as the starting point. Subsequent vertices are connected with straight line segments. After the last vertex, the path is automatically closed back to the first vertex.

The polygon is stroked and filled using the current Pen and Brush. Use SetPen and SetBrush before calling this method to control the border style and fill color.

NOTE: This method throws an exception if the current canvas is not a drawing canvas or if fewer than three vertices are supplied.

DrawRectangle Method (PDFGen Component)

Draws a rectangle on the drawing canvas.

Syntax

func (obj *PDFGen) DrawRectangle(Width string, Height string, CornerRadius string) error

Remarks

This method is used to add a rectangle to the current drawing canvas. The rectangle is defined by its bottom-left corner at the current pen position as set by MoveTo, and the specified Width and Height. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

CornerRadius specifies the radius of the rounded corners of the rectangle. If greater than 0, each corner is replaced by a circular arc of the given radius. If the radius exceeds half the shorter side of the rectangle, it is automatically clamped to that maximum.

The rectangle is stroked and filled using the current Pen and Brush. Use SetPen and SetBrush before calling this method to control the border style and fill color.

NOTE: This method throws an exception if the current canvas is not a drawing canvas.

EndComboBox Method (PDFGen Component)

Completes the combo box field.

Syntax

func (obj *PDFGen) EndComboBox() error

Remarks

This method is used to finalize the combo box field started in StartComboBox. Note that the combo box can no longer be modified after it is completed.

NOTE: This method throws an exception if the current canvas is not a text canvas.

EndContent Method (PDFGen Component)

Completes the logical section.

Syntax

func (obj *PDFGen) EndContent() error

Remarks

This method is currently unsupported.

EndDrawing Method (PDFGen Component)

Finalizes the drawing canvas and commits it to the parent canvas.

Syntax

func (obj *PDFGen) EndDrawing(ScaleX string, ScaleY string, Rotation string, SkewA string, SkewB string, CanvasId string) error

Remarks

This method is used to close the drawing canvas opened in StartDrawing and commit it to its parent canvas. Any open path on the drawing canvas is automatically closed first. Note that the drawing canvas can no longer be modified after it is closed.

If the parent canvas is a text canvas, the closed canvas is treated as an inline element and placed in the normal flow of content, following the same layout rules as text and other content. If the parent canvas is a drawing canvas, the closed canvas is placed at the current pen position of the parent canvas as set by MoveTo.

ScaleX and ScaleY specify the horizontal and vertical scale factors to apply to the canvas when placing it on the parent canvas. These parameters default to 1 if empty.

Rotation specifies the rotation angle of the canvas in degrees counterclockwise. If empty or 0, no rotation is applied.

SkewA and SkewB specify the horizontal and vertical skew angles of the canvas in degrees. SkewA shears along the X axis and SkewB shears along the Y axis. If empty or 0, no skew is applied.

The full transformation is applied in the following order: scale, skew, rotation, translation.

If CanvasId is non-empty, the closed canvas is also saved in the component under that Id and can be added to other canvases with AddCopy. Each saved Id must be unique, and a canvas that contains form fields cannot be saved.

NOTE: This method throws an exception if the current canvas is not a drawing canvas.

EndEditing Method (PDFGen Component)

Finalizes the text canvas and commits it to the parent canvas.

Syntax

func (obj *PDFGen) EndEditing(ScaleX string, ScaleY string, Rotation string, SkewA string, SkewB string, CanvasId string) error

Remarks

This method is used to close the text canvas opened in StartEditing and commit it to its parent canvas. Note that the text canvas can no longer be modified after it is closed.

If the parent canvas is a text canvas, the closed canvas is treated as an inline element and placed in the normal flow of content, following the same layout rules as text and other content. If the parent canvas is a drawing canvas, the closed canvas is placed at the current pen position of the parent canvas as set by MoveTo.

ScaleX and ScaleY specify the horizontal and vertical scale factors to apply to the canvas when placing it on the parent canvas. These parameters default to 1 if empty.

Rotation specifies the rotation angle of the canvas in degrees counterclockwise. If empty or 0, no rotation is applied.

SkewA and SkewB specify the horizontal and vertical skew angles of the canvas in degrees. SkewA shears along the X axis and SkewB shears along the Y axis. If empty or 0, no skew is applied.

The full transformation is applied in the following order: scale, skew, rotation, translation.

If CanvasId is non-empty, the closed canvas is also saved in the component under that Id and can be added to other canvases with AddCopy. Each saved Id must be unique, and a canvas that contains form fields cannot be saved.

NOTE: This method throws an exception if the current canvas is not a text canvas.

EndForm Method (PDFGen Component)

Completes and closes the current interactive form.

Syntax

func (obj *PDFGen) EndForm() error

Remarks

The method is used to complete the interactive form that was started explicitly in StartForm or implicitly via a method such as AddCheckBox or AddTextBox.

A PDF document can only contain one form, which can span multiple pages. After the form is closed, no more form fields can be added to the document.

NOTE: This method throws an exception if the current canvas is not a text canvas or if there is no active form in the document.

EndList Method (PDFGen Component)

Completes the list.

Syntax

func (obj *PDFGen) EndList(ListId string) error

Remarks

This method is used to finalize the list started in StartList. Note that the list can no longer be modified after it is completed.

ListId is reserved for future use.

NOTE: This method throws an exception if a list is not currently being edited.

EndListBox Method (PDFGen Component)

Completes the list box field.

Syntax

func (obj *PDFGen) EndListBox() error

Remarks

This method is used to finalize the list box field started in StartListBox. Note that the list box can no longer be modified after it is completed.

NOTE: This method throws an exception if the current canvas is not a text canvas.

EndListItem Method (PDFGen Component)

Completes the list item.

Syntax

func (obj *PDFGen) EndListItem(CanvasId string) error

Remarks

This method is used to finalize the list item started in StartListItem and commit the underlying text canvas to its parent canvas. Note that the list item can no longer be modified after it is completed.

CanvasId is reserved for future use.

NOTE: This method throws an exception if a list is not currently being edited.

EndParagraph Method (PDFGen Component)

Completes the paragraph.

Syntax

func (obj *PDFGen) EndParagraph(ParaId string) error

Remarks

This method is used to finalize the paragraph started in StartParagraph and add a line break so that subsequent content starts on a new line. Note that the paragraph can no longer be modified after it is completed.

ParaId is reserved for future use.

NOTE: This method only applies if the current canvas is a text canvas.

EndPath Method (PDFGen Component)

Completes the current path and applies it to the drawing canvas.

Syntax

func (obj *PDFGen) EndPath(ClosePath bool, PathId string) error

Remarks

This method is used to finalize the path started in StartPath and record it as a drawing primitive on the current drawing canvas. The path is rendered according to the drawing mode specified in StartPath when the canvas is eventually closed.

ClosePath specifies whether to close the path by drawing a straight line from the current pen position back to the path's starting point before applying the drawing mode. Pass true to close the path (useful for filled shapes), or false to leave the path open.

If PathId is non-empty, the completed path is also saved in the component under that Id and can be added to other drawing canvases with AddCopy. Each saved Id must be unique.

NOTE: This method throws an exception if the current canvas is not a drawing canvas.

EndSignatureField Method (PDFGen Component)

Completes the signature field.

Syntax

func (obj *PDFGen) EndSignatureField(ScaleX string, ScaleY string, Rotation string, SkewA string, SkewB string, CanvasId string) error

Remarks

This method is used to finalize the signature field started in StartSignatureField and commit the underlying canvas to its parent canvas. Note that the signature field canvas can no longer be modified after it is closed.

ScaleX and ScaleY are reserved for future use.

Rotation is reserved for future use.

SkewA and SkewB are reserved for future use.

CanvasId is reserved for future use.

NOTE: This method throws an exception if the current canvas is not a text canvas.

EndTable Method (PDFGen Component)

Finalizes the table canvas and commits it to the parent canvas.

Syntax

func (obj *PDFGen) EndTable(CanvasId string) error

Remarks

This method is used to close the table canvas opened in StartTable and commit it to its parent canvas. Any open cell or row in the table is automatically closed before the table layout is resolved. Note that the table canvas can no longer be modified after it is closed.

If CanvasId is non-empty, the closed canvas is also saved in the component under that Id and can be added to other canvases with AddCopy. Each saved Id must be unique, and a canvas that contains form fields cannot be saved.

NOTE: This method throws an exception if the current canvas is not a table canvas.

EndTableCell Method (PDFGen Component)

Completes the current table cell.

Syntax

func (obj *PDFGen) EndTableCell(CanvasId string) error

Remarks

This method is used to explicitly close the cell opened in StartTableCell and commit the underlying cell canvas to its parent table canvas. Note that the cell canvas can no longer be modified after it is closed.

CanvasId is reserved for future use.

It is not necessary to call this method before starting the next cell via StartTableCell, as open cells are closed implicitly at that point.

NOTE: This method throws an exception if the current canvas is not a cell canvas.

EndTableRow Method (PDFGen Component)

Completes the current table row.

Syntax

func (obj *PDFGen) EndTableRow(RowId string) error

Remarks

This method is used to explicitly close the row opened in StartTableRow. Any open cell in the row is automatically closed first, and any columns that have not been filled with a cell are padded with empty cells so that the row always spans the full column count of the table. Note that the row can no longer be modified after it is closed.

RowId is reserved for future use.

It is not necessary to call this method before starting the next row via StartTableRow, as open rows are closed implicitly at that point.

NOTE: This method throws an exception if the current canvas is not a table canvas.

GetDocumentProperty Method (PDFGen Component)

Returns the value of a document property.

Syntax

func (obj *PDFGen) GetDocumentProperty(DocumentProperty string) (string, error)

Remarks

This method is used to obtain the value of a document property. Together with SetDocumentProperty, this method provides an extensible way of managing the document settings that are not available through other means. The list of settings below may be extended in the future.

DocumentProperty specifies the document property to read. Possible values are:

Document property Default value Description
FooterFromBottom 36 The vertical offset of the footer from the bottom page border in points.
HeaderFromTop 36 The vertical offset of the header from the top page border in points.
MirrorFooters False Whether to automatically swap the left and right footers in double-sided documents. If enabled, the left and right footers will be mirrored on alternating pages.
MirrorHeaders False Whether to automatically swap the left and right headers in double-sided documents. If enabled, the left and right headers will be mirrored on alternating pages.
MirrorMargins False Whether to automatically swap the left and right margins in double-sided documents. If enabled, the left and right margins will be mirrored on alternating pages.
PageFooter "" The central footer text.
PageFooterFont Times New Roman The font name for the footer text.
PageFooterFontColor #000000 The font color for the footer text.
PageFooterFontSize 12 The font size for the footer text.
PageFooterFontStyle "" The font style for the footer text.
PageHeader "" The central header text.
PageHeaderFont Times New Roman The font name for the header text.
PageHeaderFontColor #000000 The font color for the header text.
PageHeaderFontSize 12 The font size for the header text.
PageHeaderFontStyle "" The font style for the header text.
PageLeftFooter "" The left footer text.
PageLeftHeader "" The left header text.
PageNumber 1 The starting page number in the header or footer.
PageNumberFormat Automatic The page number format. Supported values: Automatic, Alpha, AlphaCaps, Roman, RomanCaps, Numeric.
PageRightFooter "" The right footer text.
PageRightHeader "" The right header text.
UsedFonts "" A CRLF-separated list of all the fonts used in the document.
Watermark "" The watermark text to be displayed.
WatermarkFont Times New Roman The font name for the watermark text.
WatermarkFontColor #BFBFBF The font color for the watermark text.
WatermarkFontSize "" The font size for the watermark text. If empty, the watermark is automatically adjusted to fit the page.
WatermarkFontStyle "" The font style for the watermark text.
WatermarkStyle diagonal The style and placement of the watermark. Supported values: diagonal, horizontal, vertical, scattered, brickwork. The style can also include a direction separated by a space: NE/northeast, SE/southeast, NW/northwest, SW/southwest, N/north, S/south, E/east, W/west.
Xmp "" The XML body of the XMP metadata embedded in the document.
Xmp[property] "" The value of an XMP metadata property.
XmpStream "" The hex-encoded content of the XMP metadata stream.

Example: string description = pdfgen.GetDocumentProperty("Xmp[dc:description]"); string metadataXml = pdfgen.GetDocumentProperty("Xmp"); // Use language descriptors for multi-language properties string descriptionEs = pdfgen.GetDocumentProperty("Xmp[dc:description[es]]");

GetFieldProperty Method (PDFGen Component)

Returns the value of a field property.

Syntax

func (obj *PDFGen) GetFieldProperty(FieldName string, FieldProperty string) (string, error)

Remarks

This method is used to obtain the value of a field property. Together with SetFieldProperty, this method provides an extensible way of managing the field settings that are not available through other means. The list of settings below may be extended in the future.

FieldName is the name of the field of interest, and FieldProperty specifies the field property to read. Possible values are:

Field property Default value Description
AnnotationFlags 0 The field annotation flags.
AnnotationHidden False Whether the field annotation is completely invisible, meaning it cannot be displayed, printed, or interacted with.
AnnotationInvisible False Whether the field annotation is invisible on the screen and in print, but still remains interactive.
AnnotationLocked False Whether the user cannot modify the field annotation's properties, such as its position and size.
AnnotationLockedContents False Whether the user cannot modify the field annotation's contents.
AnnotationNoRotate False Whether the field annotation's orientation remains fixed regardless of the page rotation.
AnnotationNoView False Whether the field annotation is invisible on the screen and cannot be interacted with, but still appears when printed.
AnnotationNoZoom False Whether the field annotation's size remains fixed regardless of the page magnification level.
AnnotationPrint False Whether the field annotation appears when the page is printed.
AnnotationReadOnly False Whether the user cannot interact with or modify the field annotation.
AnnotationToggleNoView False Whether the field annotation's NoView flag is intended to be toggled dynamically by a user action or script.
Flags 0 The field flags.
IncludeEdit False Whether the combo box field includes an editable text box in addition to a drop-down list.
MultiLine False Whether the text box field can contain multiple lines of text.
MultiSelect False Whether multiple options can be selected simultaneously in the combo box or list box field.
NoExport False Whether the field is not exported when the form is submitted.
NoToggleToOff False Whether exactly one radio button in the radio group must always be selected.
Password False Whether the text box field is intended to contain a password.
ReadOnly False Whether the user cannot change the field's value.
Required False Whether the field must have a value before the form can be submitted.
Sort False Whether the options are automatically sorted alphabetically in the combo box or list box field.
UnisonSelect False Whether selecting one radio button automatically selects all other radio buttons in the same group that share the same field name and value for the on state.

GetPageProperty Method (PDFGen Component)

Returns the value of a page property.

Syntax

func (obj *PDFGen) GetPageProperty(PageProperty string) (string, error)

Remarks

This method is used to obtain the value of a page property for the current page. Together with SetPageProperty, this method provides an extensible way of managing the current page settings that are not available through other means. The list of settings below may be extended in the future.

PageProperty specifies the page property to read. Possible values are:

Page property Default value Description
PageFooter "" The central footer text.
PageFooterFont Times New Roman The font name for the footer text.
PageFooterFontColor #000000 The font color for the footer text.
PageFooterFontSize 12 The font size for the footer text.
PageFooterFontStyle "" The font style for the footer text.
PageHeader "" The central header text.
PageHeaderFont Times New Roman The font name for the header text.
PageHeaderFontColor #000000 The font color for the header text.
PageHeaderFontSize 12 The font size for the header text.
PageHeaderFontStyle "" The font style for the header text.
PageLeftFooter "" The left footer text.
PageLeftHeader "" The left header text.
PageNumber 1 The page number in the header or footer.
PageNumberFormat Automatic The page number format. Supported values: Automatic, Alpha, AlphaCaps, Roman, RomanCaps, Numeric.
PageRightFooter "" The right footer text.
PageRightHeader "" The right header text.
Watermark "" The watermark text to be displayed.
WatermarkFont Times New Roman The font name for the watermark text.
WatermarkFontColor #BFBFBF The font color for the watermark text.
WatermarkFontSize "" The font size for the watermark text. If empty, the watermark is automatically adjusted to fit the page.
WatermarkFontStyle "" The font style for the watermark text.
WatermarkStyle diagonal The style and placement of the watermark. Supported values: diagonal, horizontal, vertical, scattered, brickwork. The style can also include a direction separated by a space: NE/northeast, SE/southeast, NW/northwest, SW/southwest, N/north, S/south, E/east, W/west.

MoveTo Method (PDFGen Component)

Sets the current pen position on the drawing canvas.

Syntax

func (obj *PDFGen) MoveTo(X string, Y string) error

Remarks

This method is used to set the pen position on the current drawing canvas to the point specified by X and Y, relative to the bottom-left corner of the canvas. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used. If either parameter is empty, that coordinate is left unchanged.

The current pen position determines where the next element is placed on the canvas. It is used as:

NOTE: This method only applies if the current canvas is a drawing canvas.

RemoveAttachment Method (PDFGen Component)

Removes an attachment from the document.

Syntax

func (obj *PDFGen) RemoveAttachment(Index int32) error

Remarks

This method is used to remove an attachment from the document and from the Attachment* properties.

Index is the index of the attachment in the Attachment* properties to be removed.

Example: pdfgen.RemoveAttachment(0); // Alternatively, remove an attachment from Attachments manually: PDFAttachment attachment = pdfgen.Attachments[0]; pdfgen.Attachments.Remove(attachment); pdfgen.Close();

Reset Method (PDFGen Component)

Resets the class.

Syntax

func (obj *PDFGen) Reset() error

Remarks

This method is used to reset the component's properties and configuration settings to their default values.

SaveStyle Method (PDFGen Component)

Saves the currently configured font, pen, and brush as a named style.

Syntax

func (obj *PDFGen) SaveStyle(StyleId string) error

Remarks

This method is used to record the current font, pen, and brush settings under the Id given in StyleId, allowing the same look to be reapplied later with SetStyle. A style captures the settings as they are currently configured, so it reflects the accumulated result of any preceding SetFont, SetPen, and SetBrush calls.

Style Ids are case-insensitive. This method throws an exception if a style with the same Id has already been saved or if StyleId is one of the reserved built-in style names (Default, Title, H1 through H6, and P); see SetStyle for details.

Example: pdfgen.SetFont("Arial", "8", "bold", "#FF0000"); pdfgen.SaveStyle("SmallRedArial"); ... pdfgen.SetStyle("SmallRedArial"); // restores the 8pt bold red Arial font

Scroll Method (PDFGen Component)

Inserts a vertical gap into the text canvas.

Syntax

func (obj *PDFGen) Scroll(Height string) error

Remarks

This method is used to insert an empty vertical gap of Height into the current text canvas, pushing the content that follows it down by that amount. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

NOTE: This method throws an exception if the current canvas is not a text canvas.

SetAlignment Method (PDFGen Component)

Sets the alignment for subsequent text insertion operations.

Syntax

func (obj *PDFGen) SetAlignment(HorizontalAlignment int32, VerticalAlignment int32) error

Remarks

This method is used to set the horizontal and vertical alignment parameters to apply to text content, including individual pieces of text and paragraphs. Alignment specifies the position of the newly added text content within the lines of a text canvas.

HorizontalAlignment specifies the horizontal alignment relative to the left or right canvas boundaries. Possible values are:

0 (haLeft - default)
1 (haCenter)
2 (haRight)
3 (haJustify)

VerticalAlignment specifies the vertical alignment of text elements relative to each other. Possible values are:

0 (vaTop - default)
1 (vaCenter)
2 (vaBottom)

NOTE: This method only applies if the current canvas is a text or table canvas.

SetBrush Method (PDFGen Component)

Sets the fill properties used when drawing shapes and cell backgrounds.

Syntax

func (obj *PDFGen) SetBrush(Color string, Opacity string) error

Remarks

This method is used to configure the brush that is applied to the interior of all subsequently added shapes, closed paths, and table cell backgrounds.

Color specifies the fill color. If non-empty, the brush is activated and the specified color is used for all subsequent filled elements. For the full list of supported colors, see SetFont.

Opacity specifies the fill opacity as a value between 0 (fully transparent) and 1 (fully opaque). If empty, full opacity is used. Passing a non-empty opacity alone (without a color) also activates the brush using the previously stored color.

If both Color and Opacity are empty, the brush is reset to its unset state, and no fill is applied to subsequent elements. This is useful when you want a shape to be stroked only, with a transparent interior.

SetDocumentProperty Method (PDFGen Component)

Sets the value of a document property.

Syntax

func (obj *PDFGen) SetDocumentProperty(DocumentProperty string, Value string) error

Remarks

This method is used to adjust properties of the document, including those that apply globally to every page from the current page onward. Together with GetDocumentProperty, this method provides an extensible way of managing the document settings that are not available through other means. The list of settings below may be extended in the future.

DocumentProperty and Value specify the document property and value to set respectively. Possible values for the former are:

Document property Default value Description
FooterFromBottom 36 The vertical offset of the footer from the bottom page border. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.
HeaderFromTop 36 The vertical offset of the header from the top page border. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.
MirrorFooters False Whether to automatically swap the left and right footers in double-sided documents. If enabled, the left and right footers will be mirrored on alternating pages.
MirrorHeaders False Whether to automatically swap the left and right headers in double-sided documents. If enabled, the left and right headers will be mirrored on alternating pages.
MirrorMargins False Whether to automatically swap the left and right margins in double-sided documents. If enabled, the left and right margins will be mirrored on alternating pages.
PageFooter "" The central footer text.
PageFooterFont Times New Roman The font name for the footer text.
PageFooterFontColor #000000 The font color for the footer text.
PageFooterFontSize 12 The font size for the footer text. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.
PageFooterFontStyle "" The font style for the footer text.
PageHeader "" The central header text.
PageHeaderFont Times New Roman The font name for the header text.
PageHeaderFontColor #000000 The font color for the header text.
PageHeaderFontSize 12 The font size for the header text. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.
PageHeaderFontStyle "" The font style for the header text.
PageLeftFooter "" The left footer text.
PageLeftHeader "" The left header text.
PageNumber 1 The starting page number in the header or footer.
PageNumberFormat Automatic The page number format. Supported values: Automatic, Alpha, AlphaCaps, Roman, RomanCaps, Numeric.
PageRightFooter "" The right footer text.
PageRightHeader "" The right header text.
Watermark "" The watermark text to be displayed.
WatermarkFont Times New Roman The font name for the watermark text.
WatermarkFontColor #BFBFBF The font color for the watermark text.
WatermarkFontSize "" The font size for the watermark text. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used. If empty, the watermark is automatically adjusted to fit the page.
WatermarkFontStyle "" The font style for the watermark text.
WatermarkStyle diagonal The style and placement of the watermark. Supported values: diagonal, horizontal, vertical, scattered, brickwork. The style can also include a direction separated by a space: NE/northeast, SE/southeast, NW/northwest, SW/southwest, N/north, S/south, E/east, W/west.
Xmp "" The XML body of the XMP metadata embedded in the document.
Xmp[property] "" The value of an XMP metadata property.
XmpStream "" The hex-encoded content of the XMP metadata stream.

Example: pdfgen.SetDocumentProperty("PageRightHeader", "PDF 32000-1:2008"); pdfgen.SetDocumentProperty("PageLeftFooter", "© Adobe Systems Incorporated 2008 - All rights reserved"); pdfgen.SetDocumentProperty("PageRightFooter", "%PAGENUMBER%"); pdfgen.SetDocumentProperty("PageNumberFormat", "Numeric");

SetFieldProperty Method (PDFGen Component)

Sets the value of a field property.

Syntax

func (obj *PDFGen) SetFieldProperty(FieldName string, FieldProperty string, Value string) error

Remarks

This method is used to modify the value of a field property. Together with GetFieldProperty, this method provides an extensible way of managing the field settings that are not available through other means. The list of settings below may be extended in the future.

FieldName is the name of the field of interest, and FieldProperty and Value specify the field property and value to set respectively. Possible values for the former are:

Field property Default value Description
AnnotationFlags 0 The field annotation flags.
AnnotationHidden False Whether the field annotation is completely invisible, meaning it cannot be displayed, printed, or interacted with.
AnnotationInvisible False Whether the field annotation is invisible on the screen and in print, but still remains interactive.
AnnotationLocked False Whether the user cannot modify the field annotation's properties, such as its position and size.
AnnotationLockedContents False Whether the user cannot modify the field annotation's contents.
AnnotationNoRotate False Whether the field annotation's orientation remains fixed regardless of the page rotation.
AnnotationNoView False Whether the field annotation is invisible on the screen and cannot be interacted with, but still appears when printed.
AnnotationNoZoom False Whether the field annotation's size remains fixed regardless of the page magnification level.
AnnotationPrint False Whether the field annotation appears when the page is printed.
AnnotationReadOnly False Whether the user cannot interact with or modify the field annotation.
AnnotationToggleNoView False Whether the field annotation's NoView flag is intended to be toggled dynamically by a user action or script.
Flags 0 The field flags.
IncludeEdit False Whether the combo box field includes an editable text box in addition to a drop-down list.
MultiLine False Whether the text box field can contain multiple lines of text.
MultiSelect False Whether multiple options can be selected simultaneously in the combo box or list box field.
NoExport False Whether the field is not exported when the form is submitted.
NoToggleToOff False Whether exactly one radio button in the radio group must always be selected.
Password False Whether the text box field is intended to contain a password.
ReadOnly False Whether the user cannot change the field's value.
Required False Whether the field must have a value before the form can be submitted.
Sort False Whether the options are automatically sorted alphabetically in the combo box or list box field.
UnisonSelect False Whether selecting one radio button automatically selects all other radio buttons in the same group that share the same field name and value for the on state.

SetFont Method (PDFGen Component)

Sets the font properties to be applied to text.

Syntax

func (obj *PDFGen) SetFont(Name string, Size string, Style string, Color string) error

Remarks

This method is used to define the font attributes for text.

Name specifies the font name. Full font names (e.g., Times New Roman, Arial Bold Italic), filenames (e.g., times.ttf, arialbi.ttf), and full file paths are all supported.

The list of system TrueType font names that are supported by the component can be obtained from SystemFontNames.

Use FontPaths to specify font search paths when passing a TrueType font without a full file path. Alternatively, pass the full path of the TrueType font file to Name.

Size specifies the font size, either as an absolute value (e.g., 12) or relative adjustment (e.g., +2). Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Style specifies the font style. The following syntax is supported:

[B][I][U][S][bold][italic][underline][strikethrough][##%][##%,##%][0.###][0.###]

For example:

  • bold
  • bold 50%
  • bold italic 50%
  • BI 50% 42%
  • B 50% italic 0.42
If only one transparency figure is provided, it applies to both pen and brush.

Color specifies the font color in hash-prefixed hexadecimal format (such as #FF0000 for red). The following HTML color aliases are also supported:

aliceblue antiquewhite aqua aquamarine
azure beige bisque black
blanchedalmond blue blueviolet brown
burlywood cadetblue chartreuse chocolate
coral cornflowerblue cornsilk crimson
cyan darkblue darkcyan darkgoldenrod
darkgray darkgrey darkgreen darkkhaki
darkmagenta darkolivegreen darkorange darkorchid
darkred darksalmon darkseagreen darkslateblue
darkslategray darkslategrey darkturquoise darkviolet
deeppink deepskyblue dimgray dimgrey
dodgerblue firebrick floralwhite forestgreen
fuchsia gainsboro ghostwhite gold
goldenrod gray grey green
greenyellow honeydew hotpink indianred
indigo ivory khaki lavender
lavenderblush lawngreen lemonchiffon lightblue
lightcoral lightcyan lightgoldenrodyellow lightgray
lightgrey lightgreen lightpink lightsalmon
lightseagreen lightskyblue lightslategray lightslategrey
lightsteelblue lightyellow lime limegreen
linen magenta maroon mediumaquamarine
mediumblue mediumorchid mediumpurple mediumseagreen
mediumslateblue mediumspringgreen mediumturquoise mediumvioletred
midnightblue mintcream mistyrose moccasin
navajowhite navy oldlace olive
olivedrab orange orangered orchid
palegoldenrod palegreen paleturquoise palevioletred
papayawhip peachpuff peru pink
plum powderblue purple rebeccapurple
red rosybrown royalblue saddlebrown
salmon sandybrown seagreen seashell
sienna silver skyblue slateblue
slategray slategrey snow springgreen
steelblue tan teal thistle
tomato turquoise violet wheat
white whitesmoke yellow yellowgreen

SetLayout Method (PDFGen Component)

Sets the layout for new pages.

Syntax

func (obj *PDFGen) SetLayout(Size string, ColCount int32, ContentAnchor int32) error

Remarks

This method is used to set the layout parameters for new pages to be added.

Size specifies the page size as an explicit dimension pair (e.g., 400 400 or 400, 400) in which the first value defines the width and the second defines the height. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

The following named sizes are also supported:

Letter 8.5 by 11 inches, equivalent to 612 792.
A4 210 by 297 millimeters, equivalent to 595 842.
A5 148 by 210 millimeters, equivalent to 420 595.

ColCount specifies the number of columns the page will be divided into. The only value that is currently supported is 1.

ContentAnchor is reserved for future use.

SetMargin Method (PDFGen Component)

Sets the margin for a typical element.

Syntax

func (obj *PDFGen) SetMargin(MarginType int32, Value string) error

Remarks

This method is used to specify the margin to apply when adding applicable elements.

MarginType specifies the type of margin to set. Possible values are:

0 (mtTableCellTop)
1 (mtTableCellBottom)
2 (mtTableCellLeft)
3 (mtTableCellRight)
4 (mtTableCellAll)
5 (mtPageTop)
6 (mtPageBottom)
7 (mtPageLeft)
8 (mtPageRight)
9 (mtPageAll)
10 (mtListItem)
11 (mtParagraphIndent)
12 (mtColumnGap) Currently unsupported.
13 (mtLineSpacing)

Value specifies the value of the margin. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

SetPageProperty Method (PDFGen Component)

Sets the value of a page property.

Syntax

func (obj *PDFGen) SetPageProperty(PageProperty string, Value string) error

Remarks

This method is used to adjust properties of the current page, overriding the corresponding document-level properties set in SetDocumentProperty. Together with GetPageProperty, this method provides an extensible way of managing the current page settings that are not available through other means. The list of settings below may be extended in the future.

PageProperty and Value specify the page property and value to set respectively. Possible values for the former are:

Page property Default value Description
PageFooter "" The central footer text.
PageFooterFont Times New Roman The font name for the footer text.
PageFooterFontColor #000000 The font color for the footer text.
PageFooterFontSize 12 The font size for the footer text.
PageFooterFontStyle "" The font style for the footer text.
PageHeader "" The central header text.
PageHeaderFont Times New Roman The font name for the header text.
PageHeaderFontColor #000000 The font color for the header text.
PageHeaderFontSize 12 The font size for the header text.
PageHeaderFontStyle "" The font style for the header text.
PageLeftFooter "" The left footer text.
PageLeftHeader "" The left header text.
PageNumber 1 The page number in the header or footer.
PageNumberFormat Automatic The page number format. Supported values: Automatic, Alpha, AlphaCaps, Roman, RomanCaps, Numeric.
PageRightFooter "" The right footer text.
PageRightHeader "" The right header text.
Watermark "" The watermark text to be displayed.
WatermarkFont Times New Roman The font name for the watermark text.
WatermarkFontColor #BFBFBF The font color for the watermark text.
WatermarkFontSize "" The font size for the watermark text. If empty, the watermark is automatically adjusted to fit the page.
WatermarkFontStyle "" The font style for the watermark text.
WatermarkStyle diagonal The style and placement of the watermark. Supported values: diagonal, horizontal, vertical, scattered, brickwork. The style can also include a direction separated by a space: NE/northeast, SE/southeast, NW/northwest, SW/southwest, N/north, S/south, E/east, W/west.

Example: pdfgen.SetPageProperty("PageRightHeader", "PDF 32000-1:2008 (revised)");

SetPen Method (PDFGen Component)

Sets the stroke properties used when drawing lines, paths, and borders.

Syntax

func (obj *PDFGen) SetPen(Thickness string, Style string, Color string, Opacity string) error

Remarks

This method is used to configure the pen that is applied to all subsequently added paths, shapes, and table borders.

Thickness specifies the stroke width. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Style controls the dash pattern, line cap, and line join of the stroke via one or more keywords, which may appear in any order.

The following dash pattern keywords are supported:

solid A continuous unbroken line. This is the default when no dash pattern keyword is present.
dashed A line broken into equal-length dashes, equivalent to -.
dotted A line broken into short dots, equivalent to ..
dash-dot An alternating dash-dot pattern, equivalent to -..

A custom pattern can also be specified directly as a sequence of - and . characters, allowing any combination such as --. or --.-..

The following line cap keywords are supported:

butt cap A flat cap ending exactly at the endpoint.
round cap A semicircular cap extending beyond the endpoint by half the line width.
square cap A square cap extending beyond the endpoint by half the line width.

The following line join keywords are supported:

miter join limit A sharp pointed join. The optional numeric limit value immediately following the keyword sets the miter limit; when omitted, the PDF default is used.
round join A rounded join.
bevel join A flat beveled join.

Example Style strings:

dashed round cap round join A dashed line with round caps and round joins.
dotted butt cap miter join 4 A dotted line with butt caps and a miter limit of 4.
--. square cap bevel join A custom dash-dash-dot pattern with square caps and bevel joins.

Color specifies the stroke color. For the full list of supported colors, see SetFont.

Opacity specifies the stroke opacity as a value between 0 (fully transparent) and 1 (fully opaque). If empty, full opacity is used.

SetStyle Method (PDFGen Component)

Applies a previously saved style or one of the built-in styles.

Syntax

func (obj *PDFGen) SetStyle(StyleId string) error

Remarks

This method is used to apply the style identified by StyleId, which may be either a style previously saved with SaveStyle or one of the below built-in styles. Style Ids are case-insensitive, and this method throws an exception if no style with the given Id exists. Applying a style sets the font it recorded, together with the pen and brush if the style recorded them.

The following built-in styles are supported. They change only the size and boldness of the font, keeping the font family and color:

Style Font style Font size
Title bold 2.2em
H1 bold 2em
H2 bold 1.7em
H3 bold 1.5em
H4 bold 1.3em
H5 bold 1.15em
H6 bold 1em
P normal Base font's size (in points)

Additionally, Default resets the font, pen, and brush to their default values.

The heading sizes are relative to the base font size, which is the value most recently set with SetFont, not the value most recently applied by this method. Applying a style never changes the base font.

Example: pdfgen.SetFont("Arial", "12", "", ""); // the base font pdfgen.SetStyle("H1"); pdfgen.AddParagraph("Chapter One"); // a large bold Arial heading (2em) pdfgen.SetStyle("P"); pdfgen.AddParagraph("Body text..."); // back to 12pt regular Arial pdfgen.SetStyle("Default"); // Times New Roman 12pt, default pen and brush

StartComboBox Method (PDFGen Component)

Begins a new combo box field for editing.

Syntax

func (obj *PDFGen) StartComboBox(FieldName string, Width string, Height string) error

Remarks

This method is used to create a blank combo box field with name FieldName.

Width and Height specify the width and height of the combo box. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

After calling this method, use AddListItem to add choices to the combo box. When finished, call EndComboBox to complete it.

To create a combo box all at once instead of incrementally, use AddComboBox.

On a text canvas, the element is placed in the normal flow of content. On a drawing canvas, it is placed at the current pen position as set by MoveTo.

NOTE: This method throws an exception if a list is currently being edited.

StartContent Method (PDFGen Component)

Begins a new logical section.

Syntax

func (obj *PDFGen) StartContent(ContentType int32, Title string, Attributes string) error

Remarks

This method is currently unsupported.

StartDrawing Method (PDFGen Component)

Initiates a new drawing canvas of the given dimensions.

Syntax

func (obj *PDFGen) StartDrawing(Width string, Height string) error

Remarks

This method is used to create a new drawing canvas with size specified by Width and Height. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

A drawing canvas accepts vector drawing primitives such as paths, rectangles, circles, and polygons, and can also host bitmaps and nested canvases. All coordinates used within the drawing canvas are relative to its bottom-left corner.

The current Pen and Brush are inherited by the drawing canvas and applied to each new path unless overridden before the path is started. Use SetPen and SetBrush before calling path methods to control stroke and fill.

When finished editing the drawing canvas, call EndDrawing to close it and optionally save it in the component.

NOTE: This method throws an exception if a list is currently being edited.

StartEditing Method (PDFGen Component)

Initiates a new text canvas for editing.

Syntax

func (obj *PDFGen) StartEditing(Width string, Height string, ContentAnchor int32) error

Remarks

This method is used to create a blank text canvas with minimum and/or maximum dimensions specified by Width and Height. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Width and Height operate the [preferred]:[min]:[max] syntax. For example:

:100: Minimum only.
:400:400 Minimum and maximum.
::612 or 612 Maximum only.

If the minimum is empty or 0, no minimum width is enforced.

ContentAnchor is reserved for future use.

When finished editing the text canvas, call EndEditing to close it and optionally save it in the component.

Upon completion of this method, information about the newly created text canvas can be accessed using the Canvas property.

NOTE: This method throws an exception if a list is currently being edited.

StartForm Method (PDFGen Component)

Begins a new form.

Syntax

func (obj *PDFGen) StartForm(SubmitURL string) error

Remarks

This method is used to explicitly create a form. In general, it is not necessary to call this method before adding new fields via AddButton, AddCheckBox, AddRadioButton, and similar methods, as a form is created implicitly when the document is saved.

SubmitURL specifies the URL to which the form data is sent when a submit-form action is executed. Use AddButton to add a button that invokes this type of action when pressed.

When finished editing the form, call EndForm to complete it.

NOTE: This method throws an exception if the current canvas is not a text canvas.

StartList Method (PDFGen Component)

Begins a new list for editing.

Syntax

func (obj *PDFGen) StartList(Marker int32) error

Remarks

This method is used to create an empty list. If a list with at least one item is already being edited, a sublist is created.

Marker specifies the character that will precede each item in the list. Possible values are:

0 (lmOrdered)
1 (lmUnordered)
2 (lmNumeric)
3 (lmAlpha)
4 (lmAlphaCaps)
5 (lmRoman)
6 (lmRomanCaps)
7 (lmCircle)
8 (lmBlackCircle)
9 (lmBlackSquare)
10 (lmDash)
11 (lmCustom)

After calling this method, use AddListItem (or StartListItem and EndListItem) to add items to the list. When finished, call EndList to complete it and optionally save it in the component.

NOTE: This method throws an exception if the current canvas is not a text canvas.

StartListBox Method (PDFGen Component)

Begins a new list box field for editing.

Syntax

func (obj *PDFGen) StartListBox(FieldName string, Width string, Height string) error

Remarks

This method is used to create a blank list box field with name FieldName.

Width and Height specify the width and height of the list box. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

After calling this method, use AddListItem to add choices to the list box. When finished, call EndListBox to complete it.

To create a list box all at once instead of incrementally, use AddListBox.

NOTE: This method throws an exception if a list is currently being edited.

StartListItem Method (PDFGen Component)

Begins a new list item for editing.

Syntax

func (obj *PDFGen) StartListItem() error

Remarks

This method is used to create a placeholder for a list item as a text canvas. If a list item is already being edited, it is automatically completed before the new one is started.

After calling this method, use AddText or AddParagraph to populate the list item with text content. When finished, call EndListItem to close the underlying text canvas and optionally save it in the component.

To create a list item all at once instead of incrementally, use AddListItem.

NOTE: This method throws an exception if the current canvas is not a text canvas or if a list is not currently being edited.

StartParagraph Method (PDFGen Component)

Begins a new paragraph for editing.

Syntax

func (obj *PDFGen) StartParagraph() error

Remarks

This method is used to create an empty paragraph. Content added between this method and EndParagraph, such as text, links, and images, flows into the current canvas.

When finished editing the paragraph, call EndParagraph to complete it and optionally save it in the component.

To create a paragraph all at once instead of incrementally, use AddParagraph.

NOTE: This method throws an exception if a list is currently being edited.

StartPath Method (PDFGen Component)

Starts a new vector path on the drawing canvas.

Syntax

func (obj *PDFGen) StartPath(DrawingMode int32) error

Remarks

This method is used to begin a new path on the current drawing canvas, starting at the current pen position as set by MoveTo. All coordinates on a drawing canvas are relative to its bottom-left corner.

DrawingMode specifies how the path interacts with the canvas when it is closed with EndPath. Possible values are:

0 (dmDrawing) The path is rendered as a filled and/or stroked shape.
1 (dmClipping) The path defines a clipping region; subsequent drawing is masked to the interior of this path.
2 (dmMask) Reserved for future use.

The Pen and Brush active when this method is called determine the stroke color, stroke width, line style, and fill color for the path.

When finished with the path, call EndPath to complete it and optionally save it in the component.

NOTE: This method throws an exception if the current canvas is not a drawing canvas or if a list is currently being edited.

StartSignatureField Method (PDFGen Component)

Begins a new signature field for editing.

Syntax

func (obj *PDFGen) StartSignatureField(FieldName string, Width string, Height string, Drawing bool) error

Remarks

This method is used to create a blank signature field with name FieldName as either a text or drawing canvas.

Width and Height specify the width and height of the signature field. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

Drawing specifies whether the signature field will be a drawing canvas.

When finished editing the signature field, call EndSignatureField to close the underlying canvas and optionally save it in the component.

To create a signature field all at once instead of incrementally, use AddSignatureField.

NOTE: This method throws an exception if a list is currently being edited.

StartTable Method (PDFGen Component)

Initiates a new table canvas with a fixed number of columns.

Syntax

func (obj *PDFGen) StartTable(ColCount int32, Width string) error

Remarks

This method is used to create a new table canvas with ColCount columns. The table accumulates rows and cells until EndTable is called, at which point the layout is resolved and the table is committed to the parent canvas.

ColCount specifies the number of logical columns in the table. This value must be positive and cannot be changed after the table is started.

Width specifies the width constraints of the table. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

This parameter operates the [preferred]:[min]:[max] syntax. For example:

:100: Minimum only.
:400:400 Minimum and maximum.
::612 or 612 Maximum only.

If the minimum is empty or 0, no minimum width is enforced. If the maximum is empty or 0, the table may expand to fit its content without an upper bound.

The current Pen and Brush are inherited by the table and used to draw its outer border and background. Use SetPen and SetBrush before calling this method to control the table border style and fill color. Individual cells may override these settings.

After calling this method, use StartTableRow to begin adding rows, and use AddTableCell or StartTableCell to populate each row with content. When finished editing the table, call EndTable to close the underlying table canvas and optionally save it in the component.

NOTE: This method throws an exception if a list is currently being edited.

StartTableCell Method (PDFGen Component)

Begins a new cell in the current table row.

Syntax

func (obj *PDFGen) StartTableCell(Width string, ColSpan int32, RowSpan int32, Borders int32, ContentAnchor int32) error

Remarks

This method is used to open a new cell in the current row of the table canvas. Any previously opened cell in the same row is automatically closed before the new one is started.

Width specifies the cell width constraints. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

This parameter operates the [preferred]:[min]:[max] syntax. For example:

200 Preferred only.
200:50 Preferred and minimum.
200::400 Preferred and maximum.
:50: Minimum only.
::400 Maximum only.
200:50:400 Preferred, minimum, and maximum.

If the preferred width is empty or 0, the width is either inherited from the corresponding cell in the previous row or determined automatically during layout. If the minimum is empty or 0, it defaults to twice the cell padding. If the maximum is empty or 0, no maximum width is enforced.

ColSpan specifies the number of columns the cell spans horizontally. Values that would extend the cell beyond the table boundary are clamped automatically.

RowSpan specifies the number of rows the cell spans vertically. Cells covered by a rowspan from a previous row are automatically skipped when advancing through the current row.

Borders specifies which borders of the cell are suppressed. Its value should be provided as a bitmask of the following flags:

0x001 Top border
0x002 Right border
0x004 Bottom border
0x008 Left border

Pass 0 to show all borders.

ContentAnchor is reserved for future use.

The current Pen and Brush are applied to the cell background and borders. Use SetPen and SetBrush before calling this method to style individual cells.

After calling this method, add content to the cell using AddParagraph, AddText, AddBitmap, or any other method applicable to a text canvas. When finished editing the cell, call EndTableCell to close it explicitly and optionally save it in the component, or begin a new cell with StartTableCell to close it implicitly.

To create a table cell all at once instead of incrementally, use AddTableCell.

NOTE: This method throws an exception if the current canvas is not a table canvas.

StartTableRow Method (PDFGen Component)

Begins a new row in the current table.

Syntax

func (obj *PDFGen) StartTableRow(Height string, IsHeader bool) error

Remarks

This method is used to open a new row in the current table canvas. Any previously opened row is automatically closed before the new one is started.

Height specifies the row height constraints. Both integer and decimal values are supported, as are the pt, cm, mm, in, em, and % units (e.g., 5cm or 50%). If no unit is provided, points are used.

This parameter operates the [preferred]:[min]:[max] syntax. For example:

200 Preferred only.
200:50 Preferred and minimum.
200::400 Preferred and maximum.
:50: Minimum only.
::400 Maximum only.
200:50:400 Preferred, minimum, and maximum.

If the preferred height is empty or 0, the row height is determined automatically from the tallest cell it contains. If the minimum is empty or 0, the row may be as short as its content. If the maximum is empty or 0, no maximum height is enforced; otherwise, content that exceeds this height is clipped.

IsHeader specifies whether the row is a header row. This parameter is recorded for informational purposes and future use; it does not currently alter rendering behavior.

After calling this method, add cells to the row using AddTableCell or StartTableCell. When finished editing the row, call EndTableRow to close it explicitly and optionally save it in the component, or begin a new row with StartTableRow to close it implicitly.

NOTE: This method throws an exception if the current canvas is not a table canvas.

ActionRequired Event (PDFGen Component)

Fired when the class encounters a conflict that it cannot resolve on its own.

Syntax

// PDFGenActionRequiredEventArgs carries the PDFGen ActionRequired event's parameters.
type PDFGenActionRequiredEventArgs struct {...}

func (args *PDFGenActionRequiredEventArgs) Action() string
func (args *PDFGenActionRequiredEventArgs) Choice() string
func (args *PDFGenActionRequiredEventArgs) SetChoice(value string)

// PDFGenActionRequiredEvent defines the signature of the PDFGen ActionRequired event's handler function.
type PDFGenActionRequiredEvent func(sender *PDFGen, args *PDFGenActionRequiredEventArgs)

func (obj *PDFGen) GetOnActionRequiredHandler() PDFGenActionRequiredEvent
func (obj *PDFGen) SetOnActionRequiredHandler(handlerFunc PDFGenActionRequiredEvent)

Remarks

This event is reserved for scenarios where the component needs input from the user to resolve an editing conflict. Currently there are no defined conflicts, so this event does not fire.

EditingCompleted Event (PDFGen Component)

Fired after a canvas has been closed.

Syntax

// PDFGenEditingCompletedEventArgs carries the PDFGen EditingCompleted event's parameters.
type PDFGenEditingCompletedEventArgs struct {...}

func (args *PDFGenEditingCompletedEventArgs) CanvasType() int32
func (args *PDFGenEditingCompletedEventArgs) CanvasId() string
func (args *PDFGenEditingCompletedEventArgs) Width() string
func (args *PDFGenEditingCompletedEventArgs) Height() string
func (args *PDFGenEditingCompletedEventArgs) X() string
func (args *PDFGenEditingCompletedEventArgs) Y() string

// PDFGenEditingCompletedEvent defines the signature of the PDFGen EditingCompleted event's handler function.
type PDFGenEditingCompletedEvent func(sender *PDFGen, args *PDFGenEditingCompletedEventArgs)

func (obj *PDFGen) GetOnEditingCompletedHandler() PDFGenEditingCompletedEvent
func (obj *PDFGen) SetOnEditingCompletedHandler(handlerFunc PDFGenEditingCompletedEvent)

Remarks

This event is currently unsupported.

Error Event (PDFGen Component)

Fired when information is available about errors during data delivery.

Syntax

// PDFGenErrorEventArgs carries the PDFGen Error event's parameters.
type PDFGenErrorEventArgs struct {...}

func (args *PDFGenErrorEventArgs) ErrorCode() int32
func (args *PDFGenErrorEventArgs) Description() string

// PDFGenErrorEvent defines the signature of the PDFGen Error event's handler function.
type PDFGenErrorEvent func(sender *PDFGen, args *PDFGenErrorEventArgs)

func (obj *PDFGen) GetOnErrorHandler() PDFGenErrorEvent
func (obj *PDFGen) SetOnErrorHandler(handlerFunc PDFGenErrorEvent)

Remarks

The Error event is fired in case of exceptional conditions during message processing. Normally the component fails with an error.

The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

FontLookup Event (PDFGen Component)

Fired when a required font is missing.

Syntax

// PDFGenFontLookupEventArgs carries the PDFGen FontLookup event's parameters.
type PDFGenFontLookupEventArgs struct {...}

func (args *PDFGenFontLookupEventArgs) FontName() string
func (args *PDFGenFontLookupEventArgs) FontPath() string
func (args *PDFGenFontLookupEventArgs) SetFontPath(value string)

// PDFGenFontLookupEvent defines the signature of the PDFGen FontLookup event's handler function.
type PDFGenFontLookupEvent func(sender *PDFGen, args *PDFGenFontLookupEventArgs)

func (obj *PDFGen) GetOnFontLookupHandler() PDFGenFontLookupEvent
func (obj *PDFGen) SetOnFontLookupHandler(handlerFunc PDFGenFontLookupEvent)

Remarks

This event is fired from within SetFont or Close to report that the font identified by FontName was not found in FontPaths. It may be used to provide substitute fonts on the fly as an extension to the FallbackFont configuration setting.

FontPath specifies the absolute path to the substitute font file. If empty, the substitute font defaults to FallbackFont, which can also be adjusted within the event handler for each missing font.

Example: component.OnFontLookup += (s, e) => { if (e.FontName == "Helvetica") { component.Config("FallbackFont=Arial"); } else { component.Config("FallbackFont=Times New Roman"); } };

Log Event (PDFGen Component)

Fired once for each log message.

Syntax

// PDFGenLogEventArgs carries the PDFGen Log event's parameters.
type PDFGenLogEventArgs struct {...}

func (args *PDFGenLogEventArgs) LogLevel() int32
func (args *PDFGenLogEventArgs) Message() string
func (args *PDFGenLogEventArgs) LogType() string

// PDFGenLogEvent defines the signature of the PDFGen Log event's handler function.
type PDFGenLogEvent func(sender *PDFGen, args *PDFGenLogEventArgs)

func (obj *PDFGen) GetOnLogHandler() PDFGenLogEvent
func (obj *PDFGen) SetOnLogHandler(handlerFunc PDFGenLogEvent)

Remarks

This event is fired once for each log message generated by the component. The verbosity is controlled by the LogLevel configuration setting.

LogLevel indicates the detail level of the message. Possible values are:

0 (None) No messages are logged.
1 (Info - default) Informational events such as the basics of the chain validation procedure are logged.
2 (Verbose) Detailed data such as HTTP requests are logged.
3 (Debug) Debug data including the full chain validation procedure are logged.

Message is the log message.

LogType identifies the type of log entry. Possible values are:

  • CertValidator
  • Font
  • HTTP
  • PDFInvalidSignature
  • PDFRevocationInfo
  • Timestamp
  • TSL

OutOfSpace Event (PDFGen Component)

Fired when an element exceeds the maximum dimensions of the current text canvas.

Syntax

// PDFGenOutOfSpaceEventArgs carries the PDFGen OutOfSpace event's parameters.
type PDFGenOutOfSpaceEventArgs struct {...}

func (args *PDFGenOutOfSpaceEventArgs) SpaceKind() int32
func (args *PDFGenOutOfSpaceEventArgs) WidthAvailable() string
func (args *PDFGenOutOfSpaceEventArgs) WidthNeeded() string
func (args *PDFGenOutOfSpaceEventArgs) HeightAvailable() string
func (args *PDFGenOutOfSpaceEventArgs) HeightNeeded() string
func (args *PDFGenOutOfSpaceEventArgs) Choice() int32
func (args *PDFGenOutOfSpaceEventArgs) SetChoice(value int32)

// PDFGenOutOfSpaceEvent defines the signature of the PDFGen OutOfSpace event's handler function.
type PDFGenOutOfSpaceEvent func(sender *PDFGen, args *PDFGenOutOfSpaceEventArgs)

func (obj *PDFGen) GetOnOutOfSpaceHandler() PDFGenOutOfSpaceEvent
func (obj *PDFGen) SetOnOutOfSpaceHandler(handlerFunc PDFGenOutOfSpaceEvent)

Remarks

This event is fired while the component populates the text canvas to report that the content does not fit within the canvas boundaries. It can be fired from within:

SpaceKind identifies the kind of space the element has exceeded as a bitmask of the following flags:

0x001 (skWidth) The element is too wide to place within the CanvasMaxWidth of the canvas.
0x002 (skHeight) Adding the element would extend the height of the canvas beyond its CanvasMaxHeight.

WidthAvailable and HeightAvailable report the remaining width and height of the canvas in points.

WidthNeeded and HeightNeeded report the width and height of the element in points.

Choice specifies the decision requested of the component. Possible values:

0 (oscExpand) Automatically expand the canvas by just enough width and/or height to accommodate the element.
1 (oscWrap) Start a new page and place the element on the new page canvas.
2 (oscRetry) Retry the operation with a resized canvas. Use the Canvas property to adjust the CanvasMaxWidth and/or CanvasMaxHeight of the canvas within the event handler.
3 (oscSave) Currently unsupported.
4 (oscCancel) Cancel the operation as if the method that directly caused the event invocation was never called. Use this option to retry a compound method, such as EndDrawing, and complete the operation with different parameters (e.g., by applying a smaller scale to a bitmap that is too large).
5 (oscFullCancel) Cancel the compound operation entirely (i.e., both the End* call and its preceding Start* call).
6 (oscAbort - default) Cancel the operation and throw an exception.

NOTE: This event may fire repeatedly if the action the component is instructed to take does not adequately resolve the conflict.

Config Settings (PDFGen Component)

The component accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.

PDFGen Config Settings

AutoTurnPages:   Whether to change the page automatically upon exceeding the lower page boundary.

This setting specifies whether the component turns the page automatically. If set to true, the component automatically progresses to the next page upon reaching a lower page boundary while populating the current page canvas. If set to false, the OutOfSpace event fires for any elements that do not fit on the current page. The default value is true.

CompressStreams:   Whether to compress stream objects.

This setting specifies whether the bytes in the document's stream objects are compressed when the document is saved. The default value is false.

FallbackFont:   The fallback font.

This setting specifies the font that the component uses if it cannot find the intended font on the local system. In PDF/A, fonts must be embedded into the document, so this setting can be useful when text must be added but the font is not available. The default value is Times New Roman.

FontPaths:   The font search paths.

This setting specifies a CRLF-separated list of directories where the component searches for additional TrueType font files. It is used when resolving a TrueType font specified in SetFont without a full file path.

Each entry is interpreted as a directory path used during font lookup. To use a specific TrueType font file, either specify its filename and include the containing directory in this setting, or specify the full file path in SetFont.

The default value is the system font search paths. These paths are platform-dependent:

Windows %windir%\Fonts and %LOCALAPPDATA%\Microsoft\Windows\Fonts
macOS and iOS /System/Library/Fonts/, /System/Library/Fonts/Supplemental/, /Library/Fonts/, and ~/Library/Fonts/
Linux Directories listed by dir entries in /etc/fonts/fonts.conf and /usr/local/etc/fonts/fonts.conf
Android /system/fonts

On Windows, the .NET and Java editions obtain these locations through the runtime APIs or the windir, SystemRoot, and LOCALAPPDATA environment variables.

To use custom directories together with the default system locations, include both to prevent the current search path list from being replaced. For example: string fontPaths = component.Config("FontPaths"); fontPaths += @"\r\nC:\Fonts"; component.Config("FontPaths=" + fontPaths);

FontPolicy:   The font policy to follow.

This setting specifies the font policy the component follows when choosing a font, either implicitly or explicitly via SetFont. Possible values are:

TrueTypeOnly Use TrueType fonts only (e.g., Times New Roman instead of Times-Roman).
PreferTrueType (default) Use the TrueType version of the font if available; otherwise, use the corresponding built-in font.
PreferBuiltIn Use the built-in version of the font if it exists; otherwise, use the TrueType font.
BuiltInOnly Use built-in fonts only. If the desired font is only available as a TrueType font, the component throws an exception.

The 14 built-in (Type 1) fonts in PDF are: Times-Roman, Helvetica, Courier, Symbol, Times-Bold, Helvetica-Bold, Courier-Bold, ZapfDingbats, Times-Italic, Helvetica-Oblique, Courier-Oblique, Times-BoldItalic, Helvetica-BoldOblique, Courier-BoldOblique.

NOTE: If set to BuiltInOnly and PDFAConformanceLevel is not set to paclNone, the component throws an exception. This is because PDF/A requires the use of file-based TrueType fonts that can be embedded into the document.

LogLevel:   The level of detail that is logged.

This setting controls the level of detail that is logged through the Log event. Possible values are:

0 (None) No messages are logged.
1 (Info - default) Informational events such as the basics of the chain validation procedure are logged.
2 (Verbose) Detailed data such as HTTP requests are logged.
3 (Debug) Debug data including the full chain validation procedure are logged.
SaveChanges:   Whether to save changes made to the document.

This setting specifies whether and how changes made to the PDF document are saved when Close is called. Possible values are:

0 Discard all changes.
1 Save the document to OutputFile or OutputData, even if it has not been modified.
2 (default) Save the document to OutputFile or OutputData, but only if it has been modified.
SystemFontNames:   The system font names.

This setting returns a CRLF-separated list of system TrueType font names that are supported by the component. This setting is read-only.

TempPath:   The location where temporary files are stored.

This setting specifies an absolute path to the location on disk where temporary files are stored. It can be useful to reduce memory usage.

UsedFonts:   The fonts used in the document.

This setting returns a CRLF-separated list of all the fonts used in the opened document. This setting is read-only.

Base Config Settings

BuildInfo:   Information about the product's build.

When queried, this setting will return a string containing information about the product's build.

CodePage:   The system code page used for Unicode to Multibyte translations.

The default code page is Unicode UTF-8 (65001).

The following is a list of valid code page identifiers:

IdentifierName
037IBM EBCDIC - U.S./Canada
437OEM - United States
500IBM EBCDIC - International
708Arabic - ASMO 708
709Arabic - ASMO 449+, BCON V4
710Arabic - Transparent Arabic
720Arabic - Transparent ASMO
737OEM - Greek (formerly 437G)
775OEM - Baltic
850OEM - Multilingual Latin I
852OEM - Latin II
855OEM - Cyrillic (primarily Russian)
857OEM - Turkish
858OEM - Multilingual Latin I + Euro symbol
860OEM - Portuguese
861OEM - Icelandic
862OEM - Hebrew
863OEM - Canadian-French
864OEM - Arabic
865OEM - Nordic
866OEM - Russian
869OEM - Modern Greek
870IBM EBCDIC - Multilingual/ROECE (Latin-2)
874ANSI/OEM - Thai (same as 28605, ISO 8859-15)
875IBM EBCDIC - Modern Greek
932ANSI/OEM - Japanese, Shift-JIS
936ANSI/OEM - Simplified Chinese (PRC, Singapore)
949ANSI/OEM - Korean (Unified Hangul Code)
950ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)
1026IBM EBCDIC - Turkish (Latin-5)
1047IBM EBCDIC - Latin 1/Open System
1140IBM EBCDIC - U.S./Canada (037 + Euro symbol)
1141IBM EBCDIC - Germany (20273 + Euro symbol)
1142IBM EBCDIC - Denmark/Norway (20277 + Euro symbol)
1143IBM EBCDIC - Finland/Sweden (20278 + Euro symbol)
1144IBM EBCDIC - Italy (20280 + Euro symbol)
1145IBM EBCDIC - Latin America/Spain (20284 + Euro symbol)
1146IBM EBCDIC - United Kingdom (20285 + Euro symbol)
1147IBM EBCDIC - France (20297 + Euro symbol)
1148IBM EBCDIC - International (500 + Euro symbol)
1149IBM EBCDIC - Icelandic (20871 + Euro symbol)
1200Unicode UCS-2 Little-Endian (BMP of ISO 10646)
1201Unicode UCS-2 Big-Endian
1250ANSI - Central European
1251ANSI - Cyrillic
1252ANSI - Latin I
1253ANSI - Greek
1254ANSI - Turkish
1255ANSI - Hebrew
1256ANSI - Arabic
1257ANSI - Baltic
1258ANSI/OEM - Vietnamese
1361Korean (Johab)
10000MAC - Roman
10001MAC - Japanese
10002MAC - Traditional Chinese (Big5)
10003MAC - Korean
10004MAC - Arabic
10005MAC - Hebrew
10006MAC - Greek I
10007MAC - Cyrillic
10008MAC - Simplified Chinese (GB 2312)
10010MAC - Romania
10017MAC - Ukraine
10021MAC - Thai
10029MAC - Latin II
10079MAC - Icelandic
10081MAC - Turkish
10082MAC - Croatia
12000Unicode UCS-4 Little-Endian
12001Unicode UCS-4 Big-Endian
20000CNS - Taiwan
20001TCA - Taiwan
20002Eten - Taiwan
20003IBM5550 - Taiwan
20004TeleText - Taiwan
20005Wang - Taiwan
20105IA5 IRV International Alphabet No. 5 (7-bit)
20106IA5 German (7-bit)
20107IA5 Swedish (7-bit)
20108IA5 Norwegian (7-bit)
20127US-ASCII (7-bit)
20261T.61
20269ISO 6937 Non-Spacing Accent
20273IBM EBCDIC - Germany
20277IBM EBCDIC - Denmark/Norway
20278IBM EBCDIC - Finland/Sweden
20280IBM EBCDIC - Italy
20284IBM EBCDIC - Latin America/Spain
20285IBM EBCDIC - United Kingdom
20290IBM EBCDIC - Japanese Katakana Extended
20297IBM EBCDIC - France
20420IBM EBCDIC - Arabic
20423IBM EBCDIC - Greek
20424IBM EBCDIC - Hebrew
20833IBM EBCDIC - Korean Extended
20838IBM EBCDIC - Thai
20866Russian - KOI8-R
20871IBM EBCDIC - Icelandic
20880IBM EBCDIC - Cyrillic (Russian)
20905IBM EBCDIC - Turkish
20924IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol)
20932JIS X 0208-1990 & 0121-1990
20936Simplified Chinese (GB2312)
21025IBM EBCDIC - Cyrillic (Serbian, Bulgarian)
21027Extended Alpha Lowercase
21866Ukrainian (KOI8-U)
28591ISO 8859-1 Latin I
28592ISO 8859-2 Central Europe
28593ISO 8859-3 Latin 3
28594ISO 8859-4 Baltic
28595ISO 8859-5 Cyrillic
28596ISO 8859-6 Arabic
28597ISO 8859-7 Greek
28598ISO 8859-8 Hebrew
28599ISO 8859-9 Latin 5
28605ISO 8859-15 Latin 9
29001Europa 3
38598ISO 8859-8 Hebrew
50220ISO 2022 Japanese with no halfwidth Katakana
50221ISO 2022 Japanese with halfwidth Katakana
50222ISO 2022 Japanese JIS X 0201-1989
50225ISO 2022 Korean
50227ISO 2022 Simplified Chinese
50229ISO 2022 Traditional Chinese
50930Japanese (Katakana) Extended
50931US/Canada and Japanese
50933Korean Extended and Korean
50935Simplified Chinese Extended and Simplified Chinese
50936Simplified Chinese
50937US/Canada and Traditional Chinese
50939Japanese (Latin) Extended and Japanese
51932EUC - Japanese
51936EUC - Simplified Chinese
51949EUC - Korean
51950EUC - Traditional Chinese
52936HZ-GB2312 Simplified Chinese
54936Windows XP: GB18030 Simplified Chinese (4 Byte)
57002ISCII Devanagari
57003ISCII Bengali
57004ISCII Tamil
57005ISCII Telugu
57006ISCII Assamese
57007ISCII Oriya
57008ISCII Kannada
57009ISCII Malayalam
57010ISCII Gujarati
57011ISCII Punjabi
65000Unicode UTF-7
65001Unicode UTF-8
The following is a list of valid code page identifiers for Mac OS only:
IdentifierName
1ASCII
2NEXTSTEP
3JapaneseEUC
4UTF8
5ISOLatin1
6Symbol
7NonLossyASCII
8ShiftJIS
9ISOLatin2
10Unicode
11WindowsCP1251
12WindowsCP1252
13WindowsCP1253
14WindowsCP1254
15WindowsCP1250
21ISO2022JP
30MacOSRoman
10UTF16String
0x90000100UTF16BigEndian
0x94000100UTF16LittleEndian
0x8c000100UTF32String
0x98000100UTF32BigEndian
0x9c000100UTF32LittleEndian
65536Proprietary

LicenseInfo:   Information about the current license.

When queried, this setting will return a string containing information about the license this instance of a component is using. It will return the following information:

  • Product: The product the license is for.
  • Product Key: The key the license was generated from.
  • License Source: Where the license was found (e.g., RuntimeLicense, License File).
  • License Type: The type of license installed (e.g., Royalty Free, Single Server).
  • Last Valid Build: The last valid build number for which the license will work.
MaskSensitiveData:   Whether sensitive data is masked in log messages.

In certain circumstances it may be beneficial to mask sensitive data, like passwords, in log messages. Set this to true to mask sensitive data. The default is true.

UseInternalSecurityAPI:   Whether or not to use the system security libraries or an internal implementation.

When set to false, the component will use the system security libraries by default to perform cryptographic functions where applicable.

Setting this configuration setting to true tells the component to use the internal implementation instead of using the system security libraries.

On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.

To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.

Trappable Errors (PDFGen Component)

PDFGen Errors

1401   The current canvas does not support this operation.
1402   Cannot commit canvas that is still open.
1403   Invalid choice.
1404   Text canvas is not started.
1405   Page margins are too large for the current layout.
1406   Not enough space for the element.
1407   Field with specified name not found.
1408   Cannot save canvas containing form fields.
1409   The document already contains a form. Only one form per document is allowed.
1410   Form is not started.
1411   Form has already been closed.

PDF Errors

804   PDF decompression failed.
805   Cannot add entry to cross-reference table.
806   Unsupported field size.
807   Unsupported Encoding filter.
808   Unsupported predictor algorithm.
809   Unsupported document version.
812   Cannot read PDF file stream.
813   Cannot write to PDF file stream.
814   OutputFile already exists and Overwrite is false.
815   Invalid parameter.
817   Bad cross-reference entry.
818   Invalid object or generation number.
819   Invalid object stream.
820   Invalid stream dictionary.
821   Invalid AcroForm entry.
822   Invalid Root entry.
823   Invalid annotation.
824   The input document is empty.
826   OpenType font error. The error description contains the detailed message.
828   Invalid CMS data. The error description contains the detailed message.
835   Cannot change decryption mode for opened document.
836   Unsupported Date string.
838   Cryptographic error. The error description contains the detailed message.
840   DecryptionCert error. The error description contains the detailed message.
841   Encryption failed. The error description contains the detailed message.
842   No proper certificate for encryption found.
846   Unsupported revision.
847   Unsupported security handler SubFilter.
848   Failed to verify permissions.
849   Invalid password.
850   Invalid password information.
852   Unsupported encryption algorithm.
859   Cannot encrypt encrypted document.
864   Cannot modify document after signature update.
868   Cannot encrypt or decrypt object.
869   Invalid security handler information.
870   Invalid encrypted data.
871   Invalid block cipher padding.
872   Failed to reload signature.
873   Object is not encrypted.
874   Unexpected cipher information.
877   Invalid document. Bad document catalog.
878   Invalid document Id.
880   Invalid document. Invalid requirements dictionary.
881   Invalid linearization dictionary.
882   Invalid signature information.
883   Unsupported document format.
890   Unsupported feature.
891   Internal error. The error description contains the detailed message.
892   Unsupported color.
893   This operation is not supported for this PDF/A level.
894   Interactive features (Action) are not supported by PDF/A. Set PDFAConformanceLevel to paclNone or clear the Action property of the field.
895   Font file not found.
896   Invalid font name. The error description contains the detailed message.

Parsing Errors

1001   Bad object.
1002   Bad document trailer.
1003   Illegal stream dictionary.
1004   Illegal string.
1005   Indirect object expected.
1007   Invalid reference.
1008   Invalid reference table.
1009   Invalid stream data.
1010   Unexpected character.
1011   Unexpected EOF.
1012   Unexpected indirect object in cross-reference table.
1013   RDF object not found.
1014   Invalid RDF object.
1015   Cannot create element with unknown prefix.
1021   Invalid type in Root object list.