HowTo : How can I print multiple pages on a printer ?
Article | 60000445 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 3/6/2008 |
Submitted by | Graig Willox |
Keywords | |
Subject
How can I print multiple pages on a printer ?
Summary
I want to print the layouts (one layout per page) of a drawing in one print job. How can I do it ?
Solution
This applies to version 6011 and afterwards.
You should try a code like :
public void Print_Clicked()
{
//because UpdatePropertiesFromPrinter was changed and you can not change the System.Drawing.Printing.PrintDocument object of a vdPrinter
//the following logic must be used.
//Create a New printer object and set it as DocumentUnregister
vdPrint printer = new vdPrint();//new change
printer.SetUnRegisterDocument(vdPro.ActiveDocument);//new change
//Get the System.Drawing.Printing.PrintDocument from previous created vdPrinter object.
//System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();//new change
System.Drawing.Printing.PrintDocument printDoc = printer.UpdatePrinterFromProperties();//new change
System.Drawing.Printing.PrintEventArgs printArgs = new System.Drawing.Printing.PrintEventArgs();
printDoc.DocumentName = "TestPrint.pdf";
printDoc.PrinterSettings.PrinterName = "CutePDF Writer";//@\\myServer
\HP Deskjet
9800
Series
; // "Adobe PDF"; // Enter Custom PrinterName here..
//Update the printer properties
printer.UpdatePropertiesFromPrinter(printDoc);//new change
//Start multipage printing
printDoc.PrintController.OnStartPrint(printDoc, printArgs);
// Actually print each page to the printer
foreach (vdLayout layout in vdPro.ActiveDocument.LayOuts)
{
printer.SetLayout(layout);//new change
printer.CenterDrawingToPaper();//new change
printer.PrintOutPage();//new change
//layout.Printer.UpdatePropertiesFromPrinter(printDoc);
//layout.Printer.CenterDrawingToPaper();
//layout.Printer.PrintOutPage();
}
// now print them Phsyically
printDoc.PrintController.OnEndPrint(printDoc, printArgs);
}
Please try the code above and check also the remarks in this code.