70001927 Export multi page PDF for different drawings layouts

Article 70001927
Type Wish
Product Engine
Version 8006
Date Added 2/25/2021 12:00:00 AM
Fixed 9.9001.0.3 (2/25/2021 12:00:00 AM)
Submitted by Mattias Ramkvist

Summary

Export multi page PDF for different drawings layouts

Solution

In version 9001.0.3 a new object VectorDraw.Render.PrinterRender.PDFMultiPage was added
The advantage of this object procedure is that one drawing is opening each time in order to keep the memory low.

Example : Print model layouts of different drawings in to a single pdf file

//create a new printer and define the paper size of all pages for output pdf
vdPrint printer = new vdPrint();
printer.SetUnRegisterDocument(document);
printer.paperSize = new Rectangle(0, 0, 827, 1169);//select A4 paper size 8.27 x 11.69 inches
printer.LandScape = false;//select portrait paper
printer.margins = new MARGINS();//set all margins to zero
//create a new PDFMultiPage manager
VectorDraw.Render.PrinterRender.PDFMultiPage pdfmpage = new PrinterRender.PDFMultiPage(document, @"c:\myfolder\test.pdf");
if (pdfmpage.StartPrint())//begin the print out
{
    //print the model layout page of an existing drawing by fiting it to the selected printer paper
     vdDocument doc = pdfmpage.SelectDocument("drawing 1.dwg");
    if (doc != null)
    {
        printer.SetLayout(doc.Model);
        printer.PrintExtents();
        printer.PrintScaleToFit();
        pdfmpage.PrintPage(printer);
    }
    //print the model layout page of an other existing drawing by fiting it to the selected printer paper
    doc = pdfmpage.SelectDocument("drawing 2.dwg");
    if (doc != null)
    {
        printer.SetLayout(doc.Model);
        printer.PrintExtents();
        printer.PrintScaleToFit();
        pdfmpage.PrintPage(printer);
    }
    //print the model layout page of an other existing drawing by fiting it to the selected printer paper
    doc = pdfmpage.SelectDocument("drawing 3.dwg");
    if (doc != null)
    {
        printer.SetLayout(doc.Model);
        printer.PrintExtents();
        printer.PrintScaleToFit();
        pdfmpage.PrintPage(printer);
    }
    //finish the print out
    //the pdf is saved to pdfmpage passed output filename
   pdfmpage.EndPrint();
}

Send comments on this topic.