Custom print layouts
Custom print layouts enables Logtrade Connect in Business Central to print virtually anything to any print queue in any Logtrade license. Custom print layouts calls the Logtrade printing web service directly instead of going through the API that is normally used. This API requires an API key that can be obtained by contacting (support@logtrade.se). The API key contains a reference to a Logtrade license or a Logtrade license in combination with a print queue name.
Note
This is a developer framework for developing print layouts. Logtrade does not provide technical support on custom print layouts. The examples for SSCC labels and customs invoice are provided as is.
To print a custom layout you need to follow these steps:
- Create a codeunit that defines the layout to print.
- Define the custom print layout.
The custom print layout has a table number which defines the type of record it runs on and a codeunit number that defines the layout elements to print. The custom print layout has a procedure named Print that accepts a RecordId as parameter, creates an xml document for a print request and finally the specified codeunit (with the RecordId as a variant as the record parameter) that defines the layout elements.
In Logtrade Connect there is built in support for manually selecting and printing a custom layout from a package or a consignment. There's also a rule table that enables automatic print of custom layout on certain events. On top of that it is possible build custom code that calls the Print procedure of the custom layout with any kind of record to print a custom layout based on the table number of the record.
Layout methods
When defining the layout elements in a codeunit you have access to the following procedures:
Procedure name | Description | Parameters |
---|---|---|
AddPage | Adds a new page and returns an XMLNode to which the layout elements shall be added | var CurrNode: XmlNode |
AddText | Adds text | var CurrNode: XmlNode LabelText: Text Xpos: Decimal Ypos: Decimal Width: Decimal Height: Decimal Angle: Decimal Color: Enum "LTC Color" BackgroundColor: Enum "LTC Color" Alignment: Enum "LTC Alignment" FontName: Enum "LTC Font" FontSize: Decimal FontBold: Boolean FontUnderline: boolean |
AddLine | Adds a line | var CurrNode: XmlNode StartX: Decimal StartY: Decimal EndX: Decimal EndY: Decimal Color: Enum "LTC Color" BorderColor: Enum "LTC Color" PenWidth: Decimal |
AddRectangle | Adds a rectangle | var CurrNode: XmlNode StartX: Decimal StartY: Decimal EndX: Decimal EndY: Decimal Color: Enum "LTC Color" PenWidth: Decimal) |
AddEllipse | Adds an Ellipse | var CurrNode: XmlNode StartX: Decimal StartY: Decimal EndX: Decimal EndY: Decimal Color: Enum "LTC Color" BorderColor: Enum "LTC Color" PenWidth: Decimal |
AddTriangle | Adds a triangle | var CurrNode: XmlNode X1: Decimal Y1: Decimal X2: Decimal Y2: Decimal X3: Decimal Y3: Decimal Color: Text BorderColor: Text PenWidth: Decimal |
AddBitmap | Adds a bitmap | var CurrNode: XmlNode Source: Text SourceType: Enum "LTC Bitmap Source Type" Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" VerticalAlignment: Enum "LTC Vertical Alignment" |
AddRfidTag | Adds an Rfid tag | var CurrNode: XmlNode StartingBlock: Integer Format: Text StringEncoding: Enum "LTC String Encoding" |
AddEAN128Barcode | Adds an EAN128 barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" CheckDigit: Boolean Color: Text BackgroundColor: Text ShowText: Boolean XDimension: Decimal StringEncoding: Enum "LTC String Encoding" FontName: Enum "LTC Font" FontSize: Decimal FontBold: Boolean FontItalic: Boolean FontUnderline: Boolean |
AddCode128Barcode | Adds an Code128 barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" CheckDigit: Boolean Color: Text BackgroundColor: Text ShowText: Boolean XDimension: Decimal StringEncoding: Enum "LTC String Encoding" FontName: Enum "LTC Font" FontSize: Decimal FontBold: Boolean FontItalic: Boolean FontUnderline: Boolean |
AddCode39Barcode | Adds a Code39 barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal XDimension: Decimal Ratio: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" Color: Text BackgroundColor: Text ShowText: Boolean CheckDigit: Boolean StringEncoding: Enum "LTC String Encoding" FontName: Enum "LTC Font" FontSize: Decimal FontBold: Boolean FontItalic: Boolean FontUnderline: Boolean |
AddPdf417Barcode | Adds a Pdf417 barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" VerticalAlignment: Enum "LTC Vertical Alignment" Color: Text BackgroundColor: Text XDimension: Decimal Ratio: Decimal Columns: Integer StringEncoding: Enum "LTC String Encoding" |
AddMacroPdf417Barcode | Adds a Pdf417Macro barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" VerticalAlignment: Enum "LTC Vertical Alignment" Color: Text BackgroundColor: Text XDimension: Decimal Ratio: Decimal Columns: Integer MaxBarcodeSegments: Integer FileId: Text StringEncoding: Enum "LTC String Encoding" |
AddAztecBarcode | Adds an Aztec barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" VerticalAlignment: Enum "LTC Vertical Alignment" Color: Text BackgroundColor: Text CodeFormat: Enum "LTC Aztek Code Format" ErrorCorrection: Integer ModuleSize: Decimal StringEncoding: Enum "LTC String Encoding" |
AddMaxiCodeBarcode | Adds a MaxiCode barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Angle: Decimal Color: Text BackgroundColor: Text EncodingMode: Text StringEncoding: Enum "LTC String Encoding" |
AddDataMatrixBarcode | Adds a DataMatrix barcode | ar CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Color: Text BackgroundColor: Text EncodingMode: Text Format: Text ModuleSize: Decimal StringEncoding: Enum "LTC String Encoding" |
AddQrCodeBarcode | Adds a QrCode barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal Angle: Decimal Color: Text BackgroundColor: Text EncodingMode: Text ErrorCorrectionLevel: Text Version: Text ModuleSize: Decimal StringEncoding: Enum "LTC String Encoding" |
AddInterleaved2of5Barcode | Adds an Interleaved2of5 barcode | var CurrNode: XmlNode BarcodeData: Text Xpos: Decimal Ypos: Decimal Width: Integer Height: Decimal XDimension: Decimal Ratio: Decimal Angle: Decimal Alignment: Enum "LTC Alignment" Color: Text BackgroundColor: Text ShowText: Boolean CheckDigit: Boolean StringEncoding: Enum "LTC String Encoding" FontName: Enum "LTC Font" FontSize: Decimal FontBold: Boolean FontItalic: Boolean FontUnderline: Boolean |
Sample code
The built-in support for SSCC labels are utilizing the functionality for custom print layouts. You can download codeunit 12063955 "LTC SSCC Label Layout" here. You can use that codeunit as a starting point to define other layouts.
We have also created a customs invoice using the custom print layout functionality. You can download codeunit 12064002 "LTC Customs Invoice Layout" here. That layout can be used for developing other layouts for customs invoice or as inspiration for other document type reports.