| Article | 60000445 |
| Type | HowTo |
| Product | Engine |
| Date Added | 3/6/2008 12:00:00 AM |
| Fixed | (3/6/2008 12:00:00 AM) |
| Submitted by | Graig Willox |
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.
Note: This method works only if the print job is in the same printer, all pages will have the same: paper, paper size, orientation (landscape/portrait), DPI, and margins.
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.
{
//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
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();
//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..
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
printer.UpdatePropertiesFromPrinter(printDoc);//new change
//Start multipage printing
printDoc.PrintController.OnStartPrint(printDoc, printArgs);
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);
}
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.
Note for multipage PDF export check the article : http://www.vdraw.com/Export6/60000329.htm
