ExportPrintPreviewToImage Tag

ClosedDescription

Exports an entire print job (all pages) to one or more images. The images can be saved to a file, or 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 SML response. If both forms of image output are turned off, an error will be created. If both forms of image output are turned on, the images will be saved both ways.

ClosedSyntax

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

The supported attributes include:

Attribute

Required/Optional

Description

ReturnImageInResponse

Required

Returns the exported image in the Response in a base 64 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 will be saved. Required if the ReturnImageInResponse attribute equals false, otherwise it is optional.

Format

Optional

Sets the BarTender document that will be exported. If not included, BarTender will export the currently open document.

ImageFormatType

Required

Defines the type of image.

IncludeBorder

Optional

Defines if the preview images will include a border around each label.

IncludeMargins

Optional

Defines if the preview images will include page margins.

NamedSubString

Optional

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

Overwrite

Required

Defines if the file can be overwritten by files with the same name.

PrintSetup

Optional

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

QueryPrompt

Optional

Sets the query prompt options.

RecordSet

Optional

Sets 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. Refer to Supported Image Formats in the BarTender online help for a list of supported image format types.

Remember that depending upon the the configuration of the format, it is possible that <ExportPrintPreviewToImage> will 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 example below illustrates 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 will contain all of the image data in Base 64 format. The example below illustrates a response containing the image data in Base 64 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>

The previous example illustrates the size of responses that contain the image data in Base64 format. The example contains the response for a format that printed 6 labels with 6 text fields on each label. The majority of the Base64 data code was removed from the above 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 1245 lines of code when saved as a .txt file. The example does serve to remind users of the size of Base64 files and the space necessary 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 higher)

Related Topics