Search code examples
c#itextpdf-generationasposespire

How to merge multiple A4 PDFs to A3 PDF using C#


Here i want to merge two Individual A4 PDFs to A3 PDFs.The A4 PDF pages should be fit into A3 2-ups that is side by side view.

I didn't tried any code still now but before i want to know is this possible?

Note : A4 PDFs can have "N" number of pages not single page PDF.

HERE is graphical image example:

enter image description here


Solution

  • You may concatenate two PDF documents into a single PDF document containing all A4 size pages. Then you can use MakeNUp method which is exposed by PdfFileEditor class, in order to get 1 row and 2 columns on A3 size output document. Below code snippet is basic implementation of suggested approach:

    // Open first document
    Document pdfDocument1 = new Document(dataDir + "PDF1.pdf");
    // Open second document
    Document pdfDocument2 = new Document(dataDir + "PDF2.pdf");
    // Add pages of second document to the first OR vice versa
    pdfDocument1.Pages.Add(pdfDocument2.Pages);
    // Save concatenated output file
    pdfDocument1.Save(dataDir + "Concatenate.pdf");
    
    //Final step of organizing pages as per your requirements
    PdfFileEditor editor = new PdfFileEditor();
    editor.MakeNUp(dataDir + "Concatenate.pdf", dataDir + "output.pdf", 2, 1 , PageSize.A3);
    

    For further details and information, you may visit below links:

    PS: I work with Aspose as Developer Evangelist.