Assemble multiple PDF page on one page

Hi,

Is there a way to assemble multiple PDF pages on a single target page (for instance, put two originaly portrait pages on a single lanscape target) ?

Thank you for your answer,

Attachment: TwoPagesOnOne_4ee0c099.zip

3 Replies

SK Sasi Kumar Sekar Syncfusion Team November 28, 2017 05:23 AM UTC

Hi Xaviewer, 
 
Thank you for contacting Syncfusion support. 
 
We can achieve two portrait pages on single landscape page by using booklet feature in PDF. Please find the code snippet to create booklet in PDF below for your reference. 
Code snippet: 
            //Load Input PDF. 
             PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf"); 
 
            //Create booklet with two sides                
            PdfDocument pdf = PdfBookletCreator.CreateBooklet(ldoc, new SizeF(600f, 400f)); 
 
            pdf.Save("output.pdf"); 
 
 
Please find the online Booklet sample to achieve your requirement. 
 
Please try our suggestion and let us know if you need further assistance on this. 
 
Regards, 
Sasi Kumar S. 



XV Xavier VERWAERDE November 28, 2017 06:03 AM UTC

Hi Sasi,

Thank you for your quick answer.
In fact, my requirement is a bit different, because booklet gives (very efficiently) an answer for two pages on one. But, what if I need to put 4 PDF pages on one page (see picture)?
Is there a way for instance to import PDF, then scale it and put it where I need on the Graphics space?

Thank you again,

Xavier

Attachment: FourPagesOnOne_b26a4e6c.zip


SK Sasi Kumar Sekar Syncfusion Team November 29, 2017 07:03 AM UTC

Hi Xavier, 
 
Thanks for your update. 
 
At present we do not have an API to achieve your requirement, but it could be achievable by using PdfPageTemplate to create template from the existing document page and draw in new PdfPage based on bounds. Here we have created the sample that layouting Pdfpage in Single Page, please find the code snippet and sample below for your reference. 
Code snippet: 
            //Load the input PDF. 
            PdfLoadedDocument ldoc = new PdfLoadedDocument("../../data/CorporateBrochure.pdf"); 
            PdfDocument doc = new PdfDocument(); 
            doc.PageSettings.Orientation = PdfPageOrientation.Landscape; 
            doc.PageSettings.Margins.All = 0; 
            //Set Page size 
            doc.PageSettings.Size = new SizeF(600, 400); 
            PdfPage page = doc.Pages.Add(); 
            int No_of_columns_per_Row = 3; 
            int No_of_Rows_per_Page = 2; 
            float TemplateWidth = (float)(doc.Pages[0].Size.Width / No_of_columns_per_Row); 
            float TemplateHeight = (float)(doc.Pages[0].Size.Height / No_of_Rows_per_Page); 
            float TemplateX = 0; 
            float TemplateY = 0; 
            PdfTemplate template = null; 
            for (int i = 0; i < ldoc.Pages.Count; i++) 
            { 
                if (i >= 3 && i % No_of_columns_per_Row == 0) 
                { 
                    TemplateY += TemplateHeight; 
                    TemplateX = 0; 
                } 
                //Create PdfTemplate from input document page. 
                template = ldoc.Pages[i].CreateTemplate(); 
                //Draw template in page based on bounds. 
                page.Graphics.DrawPdfTemplate(template, new PointF(TemplateX, TemplateY), new SizeF(TemplateWidth, TemplateWidth)); 
                TemplateX += TemplateWidth; 
            } 
 
            doc.Save("output.pdf"); 
 
 Sample link: 
 
Please try our suggestion and let us know if you need further assistance on this. 
 
Regards, 
Sasi Kumar S. 


Loader.
Up arrow icon