Format.ExportPrintPreviewRangeToImage Method |
Exports an image for specified pages of a document's print preview.
Format.ExportPrintPreviewRangeToImage(PageRange, Directory, FileNameTemplate, FileType, Colors, DPI, backgroundColor, SaveOpts, IncludeMargins, IncludeBorder, Msgs)
Where
PageRange is a string containing the pages to export. Individual records are specified by number and separated by commas as in "1,3,5". A range of numbers indicated with a hyphen can be used to specify a series of consecutive records as in "3-8". The use of parenthesis can be used to specify the number of copies to be printer for each record (e.g. 3(5) will print 5 copies of record 3.
Directory is the path to the directory where the images will be saved.
FileNameTemplate is the file name template used when saving the file(s). If the file name template does not contain any variables, the page number will be added to the end of the file name. The supported FileNameTemplate variable is %PageNumber%. When %PageNumber% is used, the name of the file will be the current page number of the image being saved. You must also add the file type extension to the file name for the file to open properly when selected. The FileType parameter defines the file type but does not add the extension to the file name.
FileType is the image file type (jpg, gif, etc). See Supported Image Formats in the BarTender online help for a list of supported image types.
Colors sets the number of colors being used to create the image. Available options include BtColors.btColorsMono (black and white), BtColors.btColors16 (16 colors), BtColors.btColors256 (256 colors), and BtColors.btColors24bit (24bit color file).
DPI sets the resolution of the exported image. Valid values can be any number from 2 to 3000 or one of the following designated values: -1 (equal to 1 DPI), 0 (the resolution of the screen creating the image), or 1 (the resolution of the printer).
backgroundColor sets the background color of the page that displays the preview images. Valid values can be any number (24bit integer with the least significant 8 bits being red, then green, and the most significant 8 bits being blue).
SaveOpts sets when the file is saved. Available options include BtSaveOptions.btPromptSave (save when prompted), BtSaveOptions.btDoNotSaveChanges (do not save changes), and BtSaveOptions.btSaveChanges (save all changes).
IncludeMargins includes the page margins in the image. If set to false, the image will be trimmed to the edge of the labels.
IncludeBorder draws a thin black rectangle border around the label if set to true.
Msgs collects and saves any error messages created during the export for later review.
Version |
BarTender 9.4 or higher |
Edition |
Enterprise Automation |
The Format.ExportPrintPreviewRangeToImage method exports all objects created on the template with the following exceptions:
Any objects on the document that have the Preprinted option enabled will not be exported to the clipboard.
Any objects that have their ability to print disabled using the Print When option that object will not be printed.
To include these objects, use the Format object's ExportToFile method.
The ExportPrintPreviewRangeToImage method returns the following results:
BtPrintResult.btSuccess. The export was successful.
BtPrintResult.btFailure. The export failed.
'Declare a BarTender application variable
Dim btApp As BarTender.Application
'Declare a BarTender document variable
Dim btFormat As BarTender.Format
'Declare a BarTender messages variable
Dim msgs As BarTender.Messages = Nothing
'Create a new instance of BarTender
btApp = New BarTender.Application
'Set the BarTender application visible
btApp.Visible = True
'Open a BarTender document
btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
'Export pages 1, 3, 4, and 5 to a print preview
Dim res As BarTender.BtPrintResult
res = btFormat.ExportPrintPreviewRangeToImage("1,3-5", "c:\", "Label_%PageNumber%_Preview.jpg", "jpg", BarTender.BtColors.btColors24Bit, 200, 13117215, BarTender.BtSaveOptions.btSaveChanges, True, True, msgs)
'End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
// Declare a BarTender application variable
BarTender.Application btApp;
// Declare a BarTender document variable
BarTender.Format btFormat;
// Declare a BarTender messages variable
BarTender.Messages msgs;
// Create a new instance of BarTender
btApp = new BarTender.Application();
// Set the BarTender application visible
btApp.Visible = true;
// Open a BarTender document
btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");
// Export pages 1, 3, 4, and 5 to a print preview
BarTender.BtPrintResult res;
res = btFormat.ExportPrintPreviewRangeToImage("1,3-5", "c:\\", "Label_%PageNumber%_Preview.jpg", "jpg", BarTender.BtColors.btColors24Bit, 200, 13117215, BarTender.BtSaveOptions.btSaveChanges, true, true, out msgs);
// End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
Related Topics