In this section
Export Labels to PDF
Export to PDF Overview
ThermalLabel SDK allows you to export/save the output label content to Adobe PDF document format.
The object in charge for the exportation is the PrintJob. That means if you want to export a ThermalLabel object to a PDF document file (or Stream), then you will need to do that by using a PrintJob object. The generated PDF document will contain one page or multiple pages depending on the PrintJob settings.
To export a print job to a PDF file or stream you need to invoke the ExportToPdf() method of the PrintJob object. That method asks you to specify the file or stream where to save the output content and an output resolution (DPI).
The object in charge for the exportation is the PrintJob. That means if you want to export a ThermalLabel object to a PDF document file (or Stream), then you will need to do that by using a PrintJob object. The generated PDF document will contain one page or multiple pages depending on the PrintJob settings.
To export a print job to a PDF file or stream you need to invoke the ExportToPdf() method of the PrintJob object. That method asks you to specify the file or stream where to save the output content and an output resolution (DPI).
Labels to PDF samples
Example #1: The following code will export a single ThermalLabel object to PDF format at 300dpi
Visual Basic
'Define a ThermalLabel object and set unit to inch and label size Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3) tLabel.GapLength = 0.2 'Define a TextItem object Dim txtItem As New TextItem(0.2, 0.2, 1, 0.5, "Thermal Label Test") 'Define a BarcodeItem object Dim bcItem As New BarcodeItem(0.2, 1, 2, 1, BarcodeSymbology.Code128, "ABC 12345") 'Set bars height to .75inch bcItem.BarHeight = 0.75 'Set bars width to 0.0104inch bcItem.BarWidth = 0.0104 'Add items to ThermalLabel object... tLabel.Items.Add(txtItem) tLabel.Items.Add(bcItem) 'Create a PrintJob object Using pj As New PrintJob() 'Save output to PDF... pj.ExportToPdf(tLabel, "c:\temp\myLabel.pdf", 300) End Using
C#
//Define a ThermalLabel object and set unit to inch and label size ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3); tLabel.GapLength = 0.2; //Define a TextItem object TextItem txtItem = new TextItem(0.2, 0.2, 1, 0.5, "Thermal Label Test"); //Define a BarcodeItem object BarcodeItem bcItem = new BarcodeItem(0.2, 1, 2, 1, BarcodeSymbology.Code128, "ABC 12345"); //Set bars height to .75inch bcItem.BarHeight = 0.75; //Set bars width to 0.0104inch bcItem.BarWidth = 0.0104; //Add items to ThermalLabel object... tLabel.Items.Add(txtItem); tLabel.Items.Add(bcItem); //Create a PrintJob object using (PrintJob pj = new PrintJob()) { //Save output to PDF... pj.ExportToPdf(tLabel, @"c:\temp\myLabel.pdf", 300); }
Example #2: The following code will export a ThermalLabel object using Counters to a Multi-page PDF file at 300dpi