Exporting a Label to an Image

You can export a label to an image file by using the <ExportPrintPreviewToImage> tag and the use the image files to do the following:

The following example shows the <ExportPrintPreviewToImage> tag. This sample code creates a 24-bit color JPG image file that has a resolution of 300 dpi. Each image includes a border and displays the correct page margins. Because the ReturnImageInResponse attribute is set to true, the response that is returned when this command runs includes a copy of the exported images in Base64 format.

If the print job consisted of multiple pages, each page would be saved as a unique image file with a file name that includes the words "Preview Label" and the page number.

<?xml version="1.0" encoding="utf-8"?>

<XMLScript Version="2.0" Name="09232006_103601_Job1" ID="123">

<Command Name="Job1">

<ExportPrintPreviewToImage ReturnImageInResponse="true">

<Format>c:\format1.btw</Format>

<Folder>c:\Images</Folder>

<FileNameTemplate>Preview_Label%PageNumber%.jpg</FileNameTemplate>

<ImageFormatType>JPG</ImageFormatType>

<Colors>btColors24Bit</Colors>

<DPI>300</DPI>

<Overwrite>true</Overwrite>

<IncludeMargins>true</IncludeMargins>

<IncludeBorder>true</IncludeBorder>

<BackgroundColor>16777215</BackgroundColor>

</ExportPrintPreviewToImage>

</Command>

</XMLScript>

Each time that an <ExportPrintPreviewToImage> command is passed to BarTender, one or more image files are created in the target folder, and an XML response is generated. If the ReturnImageInResponse attribute is set to false, the command exports a copy of the image that can be viewed in BarTender History Explorer. If the ReturnImageInResponse attribute is set to true, the XML response contains a copy of the image in Base64 format that can be saved and viewed in BarTender History Explorer.

The exported image files and the Base64 format response might be very large. Make sure to reserve sufficient storage space.

Related Topics