HDocs_Printer Unit
- Printer component
- Starting and finishing jobs
- Grids, columns, and rows
- Text, fields, and images
- Positioning and drawing
- Job data and output options
- Fonts and language
- Job state and recovery
- Flat functions
- Other public types and constants
ThDocs_Printer
This class provides a component for managing document printing operations within an application.It is designed to handle configuration, initialization, and execution of print jobs for various types of documents.
The component includes methods for setting up print settings, generating printable content, and executing the print process.
It supports integration with other application modules to allow automated or user-driven printing tasks.
Parameters and properties allow customization of document appearance, printer selection, and additional printing options.
Build documents from code: start a job, define a grid, queue cell content, render each row, then finish the job.
Column indexes start at zero. Sizes and positions use millimeters. Render_Row draws buffered cell content and handles page breaks.
Create and Destroy
Create initializes print settings and row buffers. Destroy releases the component and its current job resources.Constructor ThDocs_Printer.Create(AOwner: TComponent);
Destructor ThDocs_Printer.Destroy;
Basic workflow
This example builds a two-column A4 document. The methods queue content until Render_Row is called.procedure PrintSample;
var
Doc: ThDocs_Printer;
begin
Doc := ThDocs_Printer.Create(nil);
try
Doc.Start_A4_Job(True, False, False, 'Sample');
try
Doc.Begin_Grid([70, 0], True, 5, 10);
Doc.Text(0, 'Item', 'B');
Doc.Text(1, 'Amount', 'BR');
Doc.Render_Row(True);
Doc.Text(0, 'Service');
Doc.Data(1, 125.50, he_Money);
Doc.Render_Row(True);
Doc.Finish_A4_Job;
except
Doc.Abort_Curr_Job;
raise;
end;
finally
Doc.Free;
end;
end;
The remaining width is assigned to column 1. For a PDF, finish with Finish_A4_Job_As_PDF instead.Start_A4_Job
Starts a fresh A4 job, discarding any unfinished job, and creates its first page. The usable canvas is 197 × 284 mm in portrait mode or 284 × 197 mm in landscape mode.Set rt_This_Job fields before this call if needed. An empty Job_Title preserves a previously assigned title.
Procedure ThDocs_Printer.Start_A4_Job(Portrait, EnaLogo, EnaPageFooter: Boolean; Job_Title: String);
Parameters
-
Portrait: Boolean; Set to True for portrait orientation, False for landscape.
-
EnaLogo: Boolean; Enable or disable printing a logo on each page.
-
EnaPageFooter: Boolean; Enable or disable printing the page footer.
-
Job_Title: String; The title assigned to the print job.
Finish_A4_Job
Finishes the A4 job with the requested action, then clears the job. The default opens a preview when dialog support is compiled in.Direct email needs a Send_By_EMail handler; the printer creates a PDF and passes its path to that handler.
Function ThDocs_Printer.Finish_A4_Job(Action: ThDocs_Printer_Action = he_Preview_Document): Boolean;
Parameters
-
Action: Selects preview, direct printing or email. The default is he_Preview_Document.
Return Value
Returns the result of the selected print, preview or email action. A canceled dialog or missing email handler returns False.ThDocs_Printer_Action
Selects the action used by Finish_A4_Job. Preview and confirmation actions depend on dialog support.ThDocs_Printer_Action = (he_Preview_Document, he_Print_Directly, he_Print_Directly_No_Dialog, he_EMail_Directly, he_ConfirmDialog);
Values
-
he_Preview_Document: Opens preview before the user selects an output action.
-
he_Print_Directly: Prints directly; a device dialog appears if no device is selected and dialogs are compiled in.
-
he_Print_Directly_No_Dialog: Prints without a device dialog.
-
he_EMail_Directly: Generates a PDF and invokes Send_By_EMail.
-
he_ConfirmDialog: Opens the preview dialog when dialog support is compiled in.
Finish_A4_Job_As_PDF
Writes the current A4 pages to FileName at the selected DPI, then clears the job. PDF security and signing options require server processing.Function ThDocs_Printer.Finish_A4_Job_As_PDF(FileName: String; DPI: ThPrint_Resolution): Boolean;
Parameters
-
FileName: String; The full path and file name for the PDF output file.
-
DPI: ThPrint_Resolution; Sets the resolution (dots per inch) for the exported PDF.
ThPrint_Resolution = (he_200dpi, he_300dpi, he_600dpi);
Return Value
Returns True when the PDF was saved successfully; otherwise returns False.Start_Envelope_Job
Begins a print job for an envelope with custom dimensions. Sets the width and height in millimeters for the print area.Procedure ThDocs_Printer.Start_Envelope_Job(Width_Mm, Height_Mm: Double);
Parameters
-
Width_Mm: Double; The width of the envelope in millimeters.
-
Height_Mm: Double; The height of the envelope in millimeters.
Finish_Envelope_Job
Completes the envelope print job. Executes the final output process for the envelope document.Function ThDocs_Printer.Finish_Envelope_Job: Boolean;
Return Value
Returns True if the envelope job completed successfully.Returns False if the operation failed.
Start_PRO_Printer_Job
Starts a job for a professional media printer using the given logical page dimensions in millimeters.Ppmm controls the metafile resolution in pixels per millimeter; EnaLogo enables the page logo callback.
Procedure ThDocs_Printer.Start_PRO_Printer_Job(Width_Mm, Logical_Page_Height_Mm: Double; EnaLogo: Boolean; Ppmm: Byte = 7);
Parameters
-
Width_Mm: Double; The width of the print area in millimeters.
-
Logical_Page_Height_Mm: Double; The logical height of the page in millimeters.
-
EnaLogo: Boolean; Enables or disables logo printing.
-
Ppmm: Byte; Sets the printer resolution in pixels per millimeter (default is 7).
Finish_PRO_Printer_Job
Finalizes the professional printer job and processes the print output.Allows specifying left and top offsets as well as a debug mode.
Function ThDocs_Printer.Finish_PRO_Printer_Job(LeftOffset, TopOffset: Word; DebugMode: Boolean): Boolean;
Parameters
-
LeftOffset: Word; Horizontal offset in printer canvas pixels.
-
TopOffset: Word; Vertical offset in printer canvas pixels.
-
DebugMode: Boolean; Displays the driver canvas size, DPI and scaling decision before printing.
Return Value
Returns True if the job completed successfully.Returns False if there was an error.
Start_POS_Thermal_Printer_Job
Begins a POS thermal print job with an 80 × 282 mm logical page at 7 pixels per millimeter.Allows enabling a logo and assigning a job title. An empty title keeps a previously assigned title.
Procedure ThDocs_Printer.Start_POS_Thermal_Printer_Job(EnaLogo: Boolean; Job_Title: String);
Parameters
-
EnaLogo: Boolean; Enables or disables logo printing on the receipt.
-
Job_Title: String; Sets the title for the print job.
Finish_POS_Thermal_Printer_Job
Completes the POS thermal printer job.Executes the print or final output process for the thermal document.
Function ThDocs_Printer.Finish_POS_Thermal_Printer_Job: Boolean;
Return Value
Returns True if the job completed successfully.Returns False if the operation failed.
NewPage
Starts a new page when the current page has content. A call before any content can keep the existing first page; page footers can still be refreshed.Procedure ThDocs_Printer.NewPage;
Sign_This_A4_Page_As_Last
Draws the last-page footer on the current A4 page and sets logo and footer flags used by subsequent pages. It only acts when a page canvas and page footer are active.Procedure ThDocs_Printer.Sign_This_A4_Page_As_Last(EnaLogo, EnaPageFooter: Boolean);
Parameters
-
EnaLogo: Boolean; Enables or disables logo printing on the last page.
-
EnaPageFooter: Boolean; Enables or disables the page footer on the last page.
Begin_Grid
Clears the pending row and defines up to 25 columns. Widths at or below zero share the remaining page width equally. Column 0 appears on the right when Right_To_Left is enabled.Space_From_Top is added to the current Y position, subject to the requested minimum space. It is not an absolute page coordinate.
Procedure ThDocs_Printer.Begin_Grid(Cols: Array OF Double; Def_Draw_Lines: Boolean; Space_From_Top, Minimal_Height_Demands: Double);
Parameters
-
Cols: Array OF Double; An array specifying the width of each column in the grid (in millimeters).
-
Def_Draw_Lines: Boolean; Enables or disables drawing default lines between columns and rows.
-
Space_From_Top: Double; The distance from the top of the page to the grid start (in millimeters).
-
Minimal_Height_Demands: Double; The minimum required height for the grid (in millimeters).
Begin_Grid_Div_Width
Builds a grid with equal widths, optionally reserving FirstColWidth for column 0. A WholeWidth below 5 mm or greater than the page width uses the full page width.Procedure ThDocs_Printer.Begin_Grid_Div_Width(ColsCount: Byte; FirstColWidth, WholeWidth: Double; Def_Draw_Lines: Boolean;
Space_From_Top, Minimal_Height_Demands: Double);
Parameters
-
ColsCount: Byte; The number of columns in the grid.
-
FirstColWidth: Double; Width of the first column (in millimeters).
-
WholeWidth: Double; Total width of the grid (in millimeters).
-
Def_Draw_Lines: Boolean; Enables or disables default line drawing for the grid.
-
Space_From_Top: Double; Space from the top of the page before the grid starts (in millimeters).
-
Minimal_Height_Demands: Double; Minimum height required for the grid (in millimeters).
Begin_Grid_For_Table
Creates equally sized columns with default grid lines by calling Begin_Grid_Div_Width.Procedure ThDocs_Printer.Begin_Grid_For_Table(ColsCount: Byte; Space_From_Top, Minimal_Height_Demands: Double);
Parameters
-
ColsCount: Byte; The number of columns in the table.
-
Space_From_Top: Double; Distance from the top of the page to the table (in millimeters).
-
Minimal_Height_Demands: Double; The minimum required height for the table (in millimeters).
Column_Props
Sets a column title and line flags. If HTable and FnTitle are supplied, the field visual name becomes the title. A nonnegative ColWidth replaces the width; call Table_Header afterward to recalculate column positions.Procedure ThDocs_Printer.Column_Props(Col: Byte; FnTitle: String; Draw_Lines: Boolean; HTable: ThTable; ColWidth: Double = -1);
Parameters
-
Col: Byte; The index of the column to configure.
-
FnTitle: String; Title or caption to be used for the column.
-
Draw_Lines: Boolean; Enables or disables line drawing for this column.
-
HTable: ThTable; Associated table object for advanced grid features.
-
ColWidth: Double; Optional replacement width; -1 leaves the current width unchanged.
Column_Lines
Sets the appearance of lines for a specific column, including left, right, and bottom lines.Procedure ThDocs_Printer.Column_Lines(Col: Byte; Left_Line, Right_Line, Bottom_Line: Boolean);
Parameters
-
Col: Byte; The column index to configure.
-
Left_Line: Boolean; Enables or disables the left border line for the column.
-
Right_Line: Boolean; Enables or disables the right border line for the column.
-
Bottom_Line: Boolean; Enables or disables the bottom border line for the column.
Table_Header
Enables a table header for the next rendered row. The header is drawn during Render_Row and repeated after a page break.Procedure ThDocs_Printer.Table_Header(Center_Title_Text: Boolean = False);
Parameters
-
Center_Title_Text: Boolean; If True, the header title is centered.
Default is False.
Column_Title
Returns the title text assigned to a specific column.An out-of-range column returns an empty string.
Function ThDocs_Printer.Column_Title(Col: Byte): String;
Parameters
-
Col: Byte; The index of the column whose title is requested.
Return Value
Returns the title text of the specified column as a String.Render_Row
Draws buffered content and clears the row buffer. Height is at least the tallest column and at least Fixed_Height. A new page starts when the row will not fit.With an empty buffer, Bottom_Horz_Line can draw bottom lines at the current Y position without advancing it.
Procedure ThDocs_Printer.Render_Row(Bottom_Horz_Line: Boolean; Fixed_Height: Double = 0);
Parameters
-
Bottom_Horz_Line: Boolean; Enables or disables drawing a horizontal line at the bottom of the row.
-
Fixed_Height: Double; Specifies a fixed height for the row (in millimeters). The row expands if its content needs more space.
Begin_Title
Begins a title section in the document using custom column widths.Sets the vertical spacing from the top and minimal height requirements.
Procedure ThDocs_Printer.Begin_Title(Cols: Array OF Double; Space_From_Top, Minimal_Height_Demands: Double);
Parameters
-
Cols: Array OF Double; An array defining the width of each column for the title section (in millimeters).
-
Space_From_Top: Double; Distance from the top of the page to the title section (in millimeters).
-
Minimal_Height_Demands: Double; Minimum required height for the title section (in millimeters).
Render_Title
Renders the title section previously defined in the document layout.This procedure draws the title area using the specified column configuration and layout properties.
Procedure ThDocs_Printer.Render_Title;
Column_Height_After_Render_Row
Returns the last rendered column position in millimeters; it includes the page Y position, so it is not the row height alone. An invalid column returns zero.Function ThDocs_Printer.Column_Height_After_Render_Row(Col: Byte): Double;
Parameters
-
Col: Byte; The index of the column for which to get the height.
Return Value
Returns the height of the specified column as a Double (in millimeters).Background
Queues a background color for selected cells in the current row. Pass an empty column array to cover every column. A nonpositive color uses the default silver background; printer settings can suppress the fill.Procedure ThDocs_Printer.Background(Cols: Array OF Byte; Color: TColor);
Parameters
-
Cols: Array OF Byte; The indices of the columns to apply the background color to.
-
Color: TColor; The color to use for the background of the specified columns.
Down
Queues a vertical offset within selected columns. Pass an empty array to offset every column. Offsets between -0.1 and 0.1 mm are ignored.Procedure ThDocs_Printer.Down(Cols: Array OF Byte; Offset: Double);
Parameters
-
Cols: Array OF Byte; The indices of columns to apply the vertical offset.
-
Offset: Double; The distance to move down in millimeters.
Text
Queues nonempty text in the selected column. The Boolean result reports whether text was queued; drawing occurs when Render_Row is called.FontStyle letters: T and M select title sizes; O reverses default horizontal alignment; L, C and R select alignment; V and Z select vertical alignment; B, I, U and S select font styles.
Function ThDocs_Printer.Text(CONST Col: Byte; CONST Text: String; CONST FontStyle: String = ''): Boolean;
Parameters
-
Col: Byte; The index of the column where the text will be placed.
-
Text: String; The content to display in the specified column.
-
FontStyle: String; Optional font style for the text (default is empty for standard style).
Return Value
Returns True when nonempty text was queued in a valid column; otherwise returns False.Data
Formats Value according to Kind and queues it as text. Supported kinds are he_Integer, he_Real, he_Money, he_Bool, he_Date, he_Hour, he_FixDT, he_Month and he_Week.An empty formatted value does not queue text. Real and money values are right aligned unless a horizontal alignment is specified.
Procedure ThDocs_Printer.Data(CONST Col: Byte; CONST Value: Double; CONST Kind: ThDataType; CONST FontStyle: String = '');
Parameters
-
Col: Byte; The index of the column where the data will be placed.
-
Value: Double; The numeric value to display.
-
Kind: ThDataType; Specifies the data type or formatting for the value.
-
FontStyle: String; Optional font style for the value (default is empty for standard style).
Field_Name
Queues an underlined field label using the table field visual name when HTable is supplied. It does not bind the column to a field.Procedure ThDocs_Printer.Field_Name(Col: Byte; FieldName: String; HTable: ThTable);
Parameters
-
Col: Byte; The index of the column to associate with the field.
-
FieldName: String; The name of the field in the table.
-
HTable: ThTable; The table object containing the field.
Field
Queues the value from HTable at Row. If PrintName is True, it queues the field visual name before the value. Missing tables or fields are ignored.Procedure ThDocs_Printer.Field(Col: Byte; HTable: ThTable; FieldName: String; Row: Integer; PrintName: Boolean; FontStyle: String = '');
Parameters
-
Col: Byte; The index of the column where the field value will be displayed.
-
HTable: ThTable; The table object containing the data.
-
FieldName: String; The name of the field whose value will be displayed.
-
Row: Integer; The row index in the table from which to get the field value.
-
PrintName: Boolean; If True, prints the field name before the value.
-
FontStyle: String; Optional font style for the displayed text.
FieldExist
Checks that the field exists and HTable.BCell is True for Row; then queues the field value. The result describes that check, not the outcome of rendering.Function ThDocs_Printer.FieldExist(Col: Byte; HTable: ThTable; FieldName: String; Row: Integer; FontStyle: String = ''; PrintName: Boolean = True): Boolean;
Parameters
-
Col: Byte; The index of the column in which to display the field value.
-
HTable: ThTable; The table object to search for the field.
-
FieldName: String; The name of the field to check in the table and display.
-
Row: Integer; The row index in the table whose field value will be displayed.
-
FontStyle: String; Optional font style for the displayed value.
-
PrintName: Boolean; Whether to print the field name together with its value.
Return Value
Returns True when the field exists and HTable.BCell is True for the row.Returns False when the field is missing, BCell is False, or the table/column is invalid.
FieldExistH
Checks that the field exists and HTable.BCell is True for Row; then queues its visual name and value on one line. The result describes that check.Function ThDocs_Printer.FieldExistH(Col: Byte; HTable: ThTable; FieldName: String; Row: Integer; FontStyle: String = ''): Boolean;
Parameters
-
Col: Byte; The index of the column in which to display the field value.
-
HTable: ThTable; The table object to search for the field.
-
FieldName: String; The name of the field to check in the table and display.
-
Row: Integer; The row index in the table whose field value will be displayed.
-
FontStyle: String; Optional font style for the displayed text.
Return Value
Returns True when the field exists and HTable.BCell is True for the row.Returns False if the field does not exist or was not displayed.
Field_Horiz
Queues a field visual name, colon and value on one line, followed by optional ConcatText.Procedure ThDocs_Printer.Field_Horiz(Col: Byte; HTable: ThTable; FieldName: String; Row: Integer; ConcatText: String = '');
Parameters
-
Col: Byte; The index of the column for output.
-
HTable: ThTable; The table object containing the field.
-
FieldName: String; The name of the field to display.
-
Row: Integer; The row index in the table.
-
ConcatText: String; Optional text to concatenate after the field value.
POS_Field
Creates a two-column grid, queues the field title and value, and renders that row immediately. It replaces any pending grid row.Procedure ThDocs_Printer.POS_Field(HTable: ThTable; FieldName: String; Row: Integer; FontStyle: String = ''; TitleStyle: String = '');
Parameters
-
HTable: ThTable; The table object containing the data.
-
FieldName: String; The name of the field whose value will be displayed.
-
Row: Integer; The row index in the table from which to get the field value.
-
FontStyle: String; Optional font style for the value.
-
TitleStyle: String; Optional font style for the field name as a title.
Barcode
Draws a barcode in the specified column using the provided text as the encoded data.The height of the barcode in millimeters can be specified.
Procedure ThDocs_Printer.Barcode(Col: Byte; Text: String; Height: Double);
Parameters
-
Col: Byte; The index of the column where the barcode will be placed.
-
Text: String; The text to encode in the barcode.
-
Height: Double; The height of the barcode in millimeters.
Image
Queues a picture in a column. The file overload accepts a local filename; when Folder is nonempty and Server exists, it resolves a database object path first.The bitmap overload passes ownership to the printer when queued: the bitmap is released after rendering or when the grid/job is reset. A height below 2 mm requests proportional sizing.
Procedure ThDocs_Printer.Image(Col: Byte; Height: Double; Folder, FileName: String); Overload;
Procedure ThDocs_Printer.Image(Col: Byte; Height: Double; Image_Will_Be_Released: TBitmap); Overload;
Parameters
-
Col: Byte; The index of the column where the image will be displayed.
-
Height: Double; Requested height in millimeters; below 2 enables automatic sizing.
-
Folder: String; Optional database object folder; pass an empty string for a local path.
-
FileName: String; The file name of the image to be displayed (only for the overload with folder and file name).
-
Image_Will_Be_Released: TBitmap; A bitmap object containing the image to display (only for the overload with TBitmap).
Icon
Draws an icon in the specified column, using the provided icon name (from ThBmpIcon container).The icon is displayed with the specified height in millimeters.
Procedure ThDocs_Printer.Icon(Col: Byte; Height: Double; IconName: String);
Parameters
-
Col: Byte; The index of the column where the icon will be placed.
-
Height: Double; The height of the icon in millimeters.
-
IconName: String; The name of the icon to be displayed.
Step_Global_YPos_In_Mm
Moves the global vertical position by the specified step in millimeters.This procedure is used to add vertical spacing or to position the next print element lower on the page.
Procedure ThDocs_Printer.Step_Global_YPos_In_Mm(Step_In_Mm: Double);
Parameters
-
Step_In_Mm: Double; The distance to move down in millimeters.
Horiz_Separator
Draws a full-width line after the requested vertical gap, with an optional second line, and advances Ypos. If it would not fit, it starts a page instead.Procedure ThDocs_Printer.Horiz_Separator(Space_From_Top: Double; DoubleLines: Boolean);
Parameters
-
Space_From_Top: Double; The vertical distance from the last position to the separator, in millimeters.
-
DoubleLines: Boolean; If True, draws a double line instead of a single line.
Draw_Floating_Line
Draws a horizontal line at absolute X and Y coordinates; W is the line length. All three values are millimeters.Procedure ThDocs_Printer.Draw_Floating_Line(X, Y, W: Double);
Draw_Floating_Round_Rect
Draws a rounded rectangle at the specified coordinates with the given width and height, using floating (absolute) positioning in millimeters.The rectangle is rendered at the specified X and Y position, sized according to W and H.
Procedure ThDocs_Printer.Draw_Floating_Round_Rect(X, Y, W, H: Double);
Parameters
-
X: Double; The X coordinate of the rectangle's top-left corner, in millimeters.
-
Y: Double; The Y coordinate of the rectangle's top-left corner, in millimeters.
-
W: Double; The width of the rectangle, in millimeters.
-
H: Double; The height of the rectangle, in millimeters.
Draw_Floating_Text_Rect
Draws a rectangle at the specified coordinates and fills it with text, using floating (absolute) positioning in millimeters.You can specify text, font style, font size, and color for the displayed text.
Procedure ThDocs_Printer.Draw_Floating_Text_Rect(X, Y, W, H: Double; Text, FontStyle: String; FontSize: Integer; Color: TColor);
Parameters
-
X: Double; The X coordinate of the rectangle's top-left corner, in millimeters.
-
Y: Double; The Y coordinate of the rectangle's top-left corner, in millimeters.
-
W: Double; The width of the rectangle, in millimeters.
-
H: Double; The height of the rectangle, in millimeters.
-
Text: String; The text to display inside the rectangle.
-
FontStyle: String; The font style to apply to the text.
-
FontSize: Integer; The font size of the text.
-
Color: TColor; The color of the text.
Draw_Floating_FillRect
Draws a filled rectangle in millimeters. A width or height below 0.01 fills the remaining page dimension. By default, fill is skipped for professional printers or when DO_NOT_Fill_Bg_Color is set; DoItAnyway overrides that check.Procedure ThDocs_Printer.Draw_Floating_FillRect(X, Y, W, H: Double; BrushColor: TColor; DoItAnyway: Boolean);
Parameters
-
X: Double; The X coordinate of the rectangle's top-left corner, in millimeters.
-
Y: Double; The Y coordinate of the rectangle's top-left corner, in millimeters.
-
W: Double; The width of the rectangle, in millimeters.
-
H: Double; The height of the rectangle, in millimeters.
-
BrushColor: TColor; The color used to fill the rectangle.
-
DoItAnyway: Boolean; If True, the rectangle will be drawn regardless of checks.
Draw_Floating_Image
Draws a TGraphic at X and Y. When W or H is zero, it draws at the graphic’s natural size; otherwise it stretches to the requested dimensions.Procedure ThDocs_Printer.Draw_Floating_Image(X, Y, W, H: Double; CONST Image: TGraphic);
Parameters
-
X: Double; The X coordinate of the image's top-left corner, in millimeters.
-
Y: Double; The Y coordinate of the image's top-left corner, in millimeters.
-
W: Double; The width of the image, in millimeters.
-
H: Double; The height of the image, in millimeters.
-
Image: TGraphic; The image object to draw.
Fields_Area
Draws a pre-defined area containing multiple fields, as specified by the ThFieldsArea object.This procedure is used to render complex layouts or grouped data fields in a single call.
Procedure ThDocs_Printer.Fields_Area(FA: ThFieldsArea);
Parameters
-
FA: ThFieldsArea; The fields area object defining the layout and data to display.
Data_Grid
Prints a ThDataGrid using its linked ThTable. It handles grids with 2 through 41 columns.For more than 11 columns, it prints successive groups of up to 10 additional columns, repeating column 0 in each group.
Procedure ThDocs_Printer.Data_Grid(DG: ThDataGrid);
Parameters
-
DG: ThDataGrid; The data grid object that defines the structure and contents to render.
Compress_Margin_On_Paper
Compresses the printed or PDF page image to leave an additional margin in millimeters. The setter caps the value at 12 mm.Property ThDocs_Printer.Compress_Margin_On_Paper: Word;
Printer_Device_Name
Defines the name of the printer device to be used for printing.This property allows selecting or querying the target printer by its device name.
Property ThDocs_Printer.Printer_Device_Name: String;
Page_Width_Mm
Returns the width of the page in millimeters.This property is read-only.
Property ThDocs_Printer.Page_Width_Mm: Double;
Page_Height_Mm
Returns the height of the page in millimeters.This property is read-only.
Property ThDocs_Printer.Page_Height_Mm: Double;
Ypos
Gets or sets the global vertical position (Y coordinate) in millimeters on the current page.Allows reading the current position or setting a new vertical position for drawing operations.
Property ThDocs_Printer.Ypos: Double;
Draw_Logo_On_Demand
Called while a new page is created when EnaLogo is enabled. Use Sender as the ThDocs_Printer instance to draw the logo on that page.Property ThDocs_Printer.Draw_Logo_On_Demand: TNotifyEvent;
Send_By_EMail
Specifies an event handler to send the generated document by email.This event allows integration with custom email delivery logic or automation after printing.
Property ThDocs_Printer.Send_By_EMail: ThdpEMailEvent;
ThdpEMailEvent
Defines an event handler type for sending a document by email.Provides information about the document name, PDF file name, and the print action, and allows confirming whether the email was sent.
ThdpEMailEvent = Procedure (Doc_Name, PDF_Fn: String; Action: ThDocs_Printer_Action; VAR Send_Confirmed: Boolean) OF Object;
Parameters
-
Doc_Name: String; The name of the document to be sent.
-
PDF_Fn: String; The file name of the PDF document to attach or send.
-
Action: ThDocs_Printer_Action; The action that triggered the email event.
-
Send_Confirmed: Boolean; Set True when the handler accepts or completes the send; it becomes Finish_A4_Job’s result.
rt_SB_Msg_Ptr
Optional status callback assigned by the caller. The printer uses it for rendering, printing and PDF progress messages.ThDocs_Printer.rt_SB_Msg_Ptr: ThTable_Statusbar_Msg;
rt_This_Job
Holds the temporary job data for the current print job.The data is cleared when a job finishes or Abort_Curr_Job is called. A new Start_* call alone does not clear it.
ThDocs_Printer.rt_This_Job: ThTemp_Job_Data;
ThTemp_Job_Data
Stores temporary data and configuration for the current print job.This record holds client and agency IDs, document title, language, and logo options.
Includes flags for international jobs, paper usage, and custom logo formatting.
Provides a procedure to clear or reset all fields.
ThTemp_Job_Data = RECORD
Client, Agency: Integer;
Title: String;
International: Boolean;
Not_For_Paper: Boolean;
Language: ThTranslation_Language;
Logo_Format: Integer;
Procedure Clear;
End;
Procedure ThTemp_Job_Data.Clear;
Fields
-
Client: Integer; The client ID associated with the print job.
-
Agency: Integer; The agency ID, used for logo selection.
-
Title: String; The title or description for the print job.
-
International: Boolean; Indicates if the job is for international use (affects logo selection).
-
Not_For_Paper: Boolean; If True, the job is not intended for paper output, but for preview or PDF; replaces stationery with a normal logo.
-
Language: ThTranslation_Language; The language setting for the print job.
-
Logo_Format: Integer; Determines the logo format for correct client app printing.
rt_Settings
Contains the font and color configuration settings for the document printer component.This structure defines visual parameters such as font styles and color schemes.
ThDocs_Printer.rt_Settings: ThDocs_Printer_Settings;
ThDocs_Printer_Settings
Defines the configuration settings for fonts and colors used by the document printer component.This record contains options for font names, sizes, color schemes, and layout directions.
It also includes settings for background filling and grid appearance.
ThDocs_Printer_Settings = PACKED RECORD
Font_Name: String;
Base_Size: Word;
Text_Size: Word;
FldName_Size: Word;
MidTitle_Size: Word;
Title_Size: Word;
Right_To_Left: Boolean;
FldName_Color: TColor;
Grid_Lines_Color: TColor;
Table_Header_Bg_Color: TColor;
DO_NOT_Fill_Bg_Color: Boolean;
End;
Fields
-
Font_Name: String; The name of the font to use for text rendering.
-
Base_Size: Word; The base font size; used for standard and small font functions.
-
Text_Size: Word; The font size for general text content.
-
FldName_Size: Word; The font size for field names.
-
MidTitle_Size: Word; The font size for middle-level titles.
-
Title_Size: Word; The font size for main titles.
-
Right_To_Left: Boolean; If True, enables right-to-left layout and text rendering.
-
FldName_Color: TColor; The color used for field names.
-
Grid_Lines_Color: TColor; The color used for grid lines.
-
Table_Header_Bg_Color: TColor; The background color for table headers.
-
DO_NOT_Fill_Bg_Color: Boolean; If True, disables background color filling; mainly for A4 printing.
Force_Default_Font
Sets a default font name and size to be used for printing. This overrides the current font settings for the job.An empty name or a size outside 8 through 72 disables the override and restores normal font selection.
Returns a Boolean value indicating if the override was set successfully.
Function ThDocs_Printer.Force_Default_Font(FontName: String; FontSize: Word): Boolean;
Parameters
-
FontName: String; The name of the font to set as default.
-
FontSize: Word; The size of the font to set as default.
Return Value
Returns True if the default font override was set.Returns False if the feature was disabled or not applied.
Reset_Settings_Back_To_Default
Resets all print settings back to their default values.This procedure is called internally when aborting or finishing a job.
Procedure ThDocs_Printer.Reset_Settings_Back_To_Default;
Set_Font_Base_Size
Sets a new base font size for all text in the print job.The new base size affects the overall appearance and scaling of text.
Procedure ThDocs_Printer.Set_Font_Base_Size(NewBaseSize: Word);
Parameters
-
NewBaseSize: Word; Accepted range is 8 through 72; outside that range the call does nothing.
Shrink_Font_Size
When enabled, sets Text_Size to Base_Size minus 2. Disabling restores Text_Size to Base_Size; other sizes do not change.Procedure ThDocs_Printer.Shrink_Font_Size(Enabled: Boolean);
Parameters
-
Enabled: Boolean; True sets Text_Size to Base_Size - 2; False restores Base_Size.
Set_Other_Language_Then_Default
Sets the print job to use a different language than the default system or application language.This allows dynamic switching of the print language for multilingual documents.
Procedure ThDocs_Printer.Set_Other_Language_Then_Default(Language: ThTranslation_Language);
Parameters
-
Language: ThTranslation_Language; The language to use for printing.
Language
Returns the currently language for the print job.This function provides access to the active translation language for document output.
Function ThDocs_Printer.Language: ThTranslation_Language;
Return Value
Returns the language in use as a ThTranslation_Language value.TC
Translates the specified text to the current print job language, if a translation is available.Returns the translated text as a string.
Function ThDocs_Printer.TC(CONST Text: String): String;
Parameters
-
Text: String; The text string to translate.
Return Value
Returns the translated text as a String.Abort_Curr_Job
Releases buffered pages and row content, clears rt_This_Job and restores default print settings. It does not call VCL Printer.Abort.Procedure ThDocs_Printer.Abort_Curr_Job;
Reset_Delphi_Printer
Resets the VCL printer selection. Use it when the printer list or selected device has changed.Procedure ThDocs_Printer.Reset_Delphi_Printer;
Job_Is_Open
Checks if a print job is currently open and active.Returns a Boolean value indicating the print job status.
Function ThDocs_Printer.Job_Is_Open: Boolean;
Return Value
Returns True if a job is open.Returns False if there is no active job.
Job_Page_Count
Returns the number of pages in the current print job.This function provides access to the page count of the active job.
Function ThDocs_Printer.Job_Page_Count: Integer;
Return Value
Returns the number of pages in the current print job as an Integer.Flat Functions
Set_Print_Job_Language
Sets the language for all tables in the given array.If the ON_Off parameter is True, the language is set according to the current job settings of the specified printer.
If ON_Off is False, default value is set.
Procedure Set_Print_Job_Language(Prn: ThDocs_Printer; Tbls: Array OF ThTable; ON_Off: Boolean = False);
Parameters
-
Prn: ThDocs_Printer; The printer component whose current job language settings may be used.
-
Tbls: Array OF ThTable; The array of tables for which to set the language.
-
ON_Off: Boolean; True applies Prn.rt_This_Job.Language to the printer and each nonnil table; False passes he_Unknown to restore default language selection.
Other public types and constants
ThDocs_Printer_Max_Columns = 25
limits grid columns; excess widths passed to Begin_Grid are ignored.ThDocs_Printer_Image_Bank = 25
limits queued bitmap slots for a row.ThDocs_Printer_Orientation
declares default, portrait and landscape values for printer dialogs.Thdp_Grid_Column
stores title, geometry and line flags for one grid column.Procedure Thdp_Grid_Column_Helper.Clear;
ThPrinter_Props_Record
stores print-dialog choice, page selection and page range; its Clear helper resets all values.Procedure ThPrinter_Props_Record_Helper.Clear;
ThDocs_Printer_Page
stores a rendered metafile, page selection flag and text direction.On Windows, ThDocs_Printer_Image_Type is TMetaFile and ThDocs_Printer_Canvas is TMetaFileCanvas.
ThPDF_Processor_Message
is the packed message sent to the PDF signing/encryption service.The global PDF_Service_DBO and Post_Msg_To_Server_Side_Username configure that service. PDF_Auto_Response_Flag tracks its reply.
Hprinter_Footer_Credits supplies optional footer text.
Response_Msg_From_Server_Type10
Updates PDF_Auto_Response_Flag from a type 10 server response whose payload starts with PDF=. The PDF processing flow calls this when the server replies.Procedure Response_Msg_From_Server_Type10(Source: ThMemoryStream);