Prod.: Engine, ver.: 6, ID: 60000445, HowTo : How can I print multiple pages on a printer ?

HowTo : How can I print multiple pages on a printer ?

Article60000445
TypeHowTo
ProductEngine
Version6
Date Added3/6/2008
Submitted byGraig 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.
 
Note for multipage PDF export check the article : http://www.vdraw.com/Export6/60000329.htm