ExportPrintPreviewToImage Tag

ClosedDescription

Exports an entire print job (all pages) to one or more images. The images can be saved to one or more files and can be returned as Base64-encoded data in the response.

If the FileNameTemplate value is empty, the images are not written to files. If the ReturnImageInResponse attribute is false, the images are not returned in Base64 format data in the response. If both forms of image output are turned off, an error is generated. If both forms of image output are turned on, the images are saved both ways.

ClosedSyntax

<ExportPrintPreviewToImage ReturnImageInResponse=Value>...</ExportPrintPreviewToImage>

The supported attributes include the following.

Attribute

Required/Optional

Description

ReturnImageInResponse

Required

Returns the exported image in the Response in a Base64 format if set to true.

ClosedChild Elements

The following child element tags are supported.

Tag

Required/Optional

Description

BackgroundColor

Required

Defines the background color of the preview image.

Colors

Required

Defines the number of colors to use in the preview images.

DPI

Required

Defines the number of dots per inch to use in the preview images.

FileNameTemplate

Required

Defines the file name template to use when saving multiple preview images. Required if the ReturnImageInResponse attribute equals false; otherwise, it is optional.

Folder

Required

Defines the folder location where the print preview images are saved. Required if the ReturnImageInResponse attribute equals false; otherwise, it is optional.

Format

Optional

Sets the BarTender document that is exported. If not included, BarTender exports the currently open document.

ImageFormatType

Required

Defines the type of image.

IncludeBorder

Optional

Specifies whether the preview images include a border around each label.

IncludeMargins

Optional

Specifies whether the preview images include page margins.

NamedSubString

Optional

Sets the name and value of a data source on a template.

Overwrite

Required

Specifies whether the file can be overwritten by files that have the same name.

PrintSetup

Optional

Sets the document's print options. If not included, BarTender uses the current print setup options.

QueryPrompt

Optional

Sets the query prompt options.

RecordSet

Optional

Specifies how BarTender uses record set data.

ClosedParent Tag

<Command>

ClosedRemarks

The <ExportPrintPreviewToImage> command creates image files of the documents in a format file. The images can be saved as any supported image format. For a list of supported image format types, refer to Supported Image Formats in the BarTender online help.

Remember that depending on the configuration of the format, <ExportPrintPreviewToImage> might generate a large number of image files. Ensure that you have memory available to store all of the files that will be generated.

If a BarTender document has one item per page, each image file will represent only one item. But, if the document has multiple items per page, each image file will represent a page with multiple items on it.

ClosedResponse

Each time an <ExportPrintPreviewToImage> command is passed to BarTender an XML response is generated. If the ReturnImageInResponse attribute is set to false, the response contains user, server and command information followed by the <ExportPrintPreviewToImage> command as an empty element tag: <ExportPrintPreviewToImage/>. The closing tags for command and the response follow. The following example shows a response.

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

<Response Version="2.0" Name="09232006_103601_Job1" ID="123" AppName="BarTender" AppVersion="9.00" AppVersionId="900" AppVersionMajor="9" AppVersionMinor="00" AppVersionBuild="2345" AppInstancePid="12345" AppInstanceGUID="(5EFC7975-14BC-11CF-9B2B-00AA00573819)">

<User>Administrator</User>

<Server>MyServer</Server>

<Command Name="Job1">

<ExportPrintPreviewToImage/>

</Command>

</Response>

If the ReturnImageInResponse attribute is set to true, the response contains all of the image data in Base64 format. The following example shows a response that contains the image data in Base64 format.

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

<Response Version="2.0" Name="09232006_103601_Job1" ID="123" AppName="BarTender" AppVersion="9.00" AppVersionId="900" AppVersionMajor="9" AppVersionMinor="00" AppVersionBuild="2345" AppInstancePid="12345" AppInstanceGUID="(5EFC7975-14BC-11CF-9B2B-00AA00573819)">

<User>Administrator</User>

<Server>MyServer</Server>

<Command Name="Job1">

<ExportPrintPreviewToImage>

<ImageData ImageFormatType="jpg" Page="1">/9j/4AAQSkZJRgABAAEBLAEsAAD//gAfTEVBRCBUZWNobm9s

b2dpZXMgSW5jLiBWMS4wMQD/2wBDAAICAgICAgICAgICAgIC

AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC

AgICAgICAgICAgICAgL/xAGiA...

                      ...AUAFABQAUAFABQAUAFAB

QAUAFABQAUAFABQAUAFABQAUAFABQAUAFAH/2Q==</ImageData>

</ExportPrintPreviewToImage>

</Command>

</Response>

This example illustrates the large size of responses that contain the image data in Base64 format. The example contains the response for a document that printed six items that have six text fields on each template. The majority of the Base64 data code was removed from this example, because the purpose was to demonstrate the structure of the file, not to show the entire content of the response. The entire response was a 64KB file that included 1,245 lines of code when it was saved as a .txt file. The example serves to remind users of the size of Base64 files and the space that is needed to store such files.

ClosedCommand Example

<?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>

ClosedRequirements

BTXML Script version 2.0 (BarTender 9.0 and later versions)

Related Topics