Accusoft.PrintPro7.Net
Print to a File
Send Feedback
PrintPRO 7 for .NET - User Guide > How To > Print > Print to a File

Glossary Item Box

This sample shows that with PrintPRO printing to a file is very much the same as generating printer output but with a few properties set to the appropriate values. Any printer output, regardless of how it is generated, can be easily directed to a file.

Example Copy Code
// generic Printer object, this is a real printer or a file depending on the user's selection
Accusoft.PrintProSdk.Printer printer;  
Accusoft.PrintProSdk.PrintJob job;   // object representation of a print job
 
// prompt the user for the desired printer
printer = Accusoft.PrintProSdk.Printer.SelectPrinter(pp, true);
 
string destinationFile = System.IO.Path.Combine(Application.StartupPath, "PrintToFile.tif");
 
// create a file printer
printer = Accusoft.PrintProSdk.Printer.CreateFilePrinter(pp, destinationFile, Accusoft.PrintProSdk.SaveFileType.Tif);
 
// Set the dpi so the generated file is not too large.
// The resulting image will be the selected dpi times the printable area
    // (slightly smaller than 8.5x11 because of margins).
printer.RequestedDpi = 100;
 
if(printer != null)
{
  // Create a PrintJob object for the above-selected Printer.
  // If the printer is not specified, PrintPRO will just use Window's default printer.
  job = new Accusoft.PrintProSdk.PrintJob(printer);
  job.Name = "Accusoft PrintPRO Demo";
  System.Drawing.Font font =
           new System.Drawing.Font("Arial",24,System.Drawing.FontStyle.Bold);
  job.Draw.TextAligned(new System.Drawing.RectangleF(1000,job.TopMargin,
           job.PaperWidth - 2000, 1100 - job.TopMargin), Hello! Check out PrintPRO!", font, 
           Accusoft.PrintProSdk.Alignment.CenterJustifyMiddle);
 
  // Finish the print job to the end of the current page and print the document */
  job.Finish();
}

 

©2013. Accusoft Corporation. All Rights Reserved.