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 that contains the pages to export. Individual records are specified by number and separated by commas (for example, "1,3,5"). A range of numbers that is indicated with a hyphen can be used to specify a series of consecutive records (for example, "3-8"). Parentheses can be used to specify the number of copies to be printed for each record (for example, "3(5)" prints five copies of record 3).
Directory is the path to the directory where the images are saved.
FileNameTemplate is the file name template that is used when the files are saved. If the file name template does not contain any variables, the page number is added to the end of the file name. The supported FileNameTemplate variable is %PageNumber%. When %PageNumber% is used, the name of the file is the current page number of the image that is being saved. You must also add the file type extension to the file name for the file to open correctly when it is selected. The FileType parameter defines the file type but does not add the extension to the file name.
FileType is the image file type (such as JPG, GIF, and so on). For a list of supported image types, refer to Supported Image Formats in the BarTender online help system.
Colors sets the number of colors that are used to create the image. Available options include BtColors.btColorsMono (black and white), BtColors.btColors16 (16 colors), BtColors.btColors256 (256 colors), BtColors.btColors24bit (24bit color file), and BtColors.btColors32bit (32bit color file). BtColors.btColors32bit supports exporting the object with a transparent background.
DPI sets the resolution of the exported image in dots per inch (dpi). 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 that creates the image)
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 (24-bit 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. When this is set to false, the image is trimmed to the edge of the labels.
IncludeBorder draws a thin black rectangular border around the label when set to true.
Msgs collects and saves any error messages that were created during the export process for later review.
Version |
BarTender 9.4 or higher |
Edition |
Enterprise |
The Format.ExportPrintPreviewRangeToImage method exports all objects that are created on the template, with the following exceptions:
Any objects on the document for which the Preprinted option is selected are not exported to the Clipboard.
Any objects for which the Print When option is used to disable printing are not 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 to 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 to 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