When writing automation code as part of integrating printing with Raster Image Printer in custom programs and workflows, the built-in Print to File capability when printing offers a quick way to dynamically control the output name and location of the created file while automatically suppressing prompting. All other conversion settings to control the output file type are determined by the profile selected on the Raster Image Printer 12 printer when printing.
The Office products, Word, Excel, PowerPoint, Publisher and Visio have this capability, Outlook does not. This technique can be used in VBA macros and scripts, and anywhere else you can automate the Office products. Other applications that have a COM interface for automation and printing may also support this. Look for arguments similar to PrintToFile and OutputFileName as part of the print method.
In Word, Excel and Visio, the PrintToFile argument needs to be set to true as well as passing the full path to the desired output file in a separate argument. For Publisher and PowerPoint, supplying the full path in the PrintToFile argument is all that is needed.
Document.PrintOut(Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight) |
Workbook.PrintOutEx(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas) |
Presentation.PrintOut(From, To, PrintToFile, Copies, Collate) |
Document.PrintOutEx(From, To, PrintToFile, Copies, Collate, PrintStyle) |
Document.PrintOut(PrintRange, FromPage, ToPage, ScaleCurrentViewToPaper, PrinterName, PrintToFile, OutputFileName, Copies, Collate, ColorAsBlack) |
The Word VBA macro below prints the currently open document to the Raster Image Printer printer and saves it to the folder C:\AutoPrint\ with the name MacroTest.jpg.
The output folder needs to exists or the macro will fail. The output file is overwritten each time the macro is run. All other settings used to create the file are taken from the profile set on the printer.
This macro is also included in the sample Word file, Raster Image Printer VBA MACRO.docm in the COMSamples\VBA Macro folder of the installation folder. This is usually C:\Program Files\Raster Image Printer 12\COMSamples\.
This same type of macro can be created from any Office application that supports macros.
Sub PrintToFile() |
A sample C# application is provided as part of the install to demonstrate using this in your own programs. This sample shows using the Print to File technique using each of the supported Office applications. The sample includes references to the Office 2016 products Word, Excel, PowerPoint, Publisher and Visio to automate printing to the Raster Image Printer printer. If you have a different version of Office installed, you will need to update the references in order to build and run the samples.
The sample, PrintToFile, can be found in the COMSamples folder of the installation folder. This is usually C:\Program Files\Raster Image Printer 12\COMSamples\.
A pre-built demo of the sample is available in a \Demo folder under the project.