PDF Mosaic: How to copy pages from one PDF to another PDF document


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This example shows how to extract pages from one PDF document (“Text.pdf”) and merge them with another existing document (“Images.pdf”) and then save them into “MergeDocument.pdf” document file.


 

C# :

using PDFMosaic;
using System;
 
namespace MergePDFs
{
    class MergePDFs
    {
        static void Main(string[] args)
        {
            // Open the first document
            PDFDocument documentImages = new PDFDocument(“Images.pdf);
            // Open the second document
            PDFDocument documentText = new PDFDocument(“Text.pdf);
 
            // Copy pages from one pdf to another pdf
            for(int i = 0; i < documentText.Pages.Count; ++i)
            documentImages.Pages.Add(documentText.Pages[i]);
 
            // Save merged document
            documentImages.Save(“MergeDocument.pdf”, true);
        }
    }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System
 
Module MergePDFs
  Sub Main()
  ' Open the first document
  Dim documentImages As New PDFDocument(“Images.pdf)
  ' Open the second document
  Dim documentText As New PDFDocument(“Text.pdf)
 
  ' Copy pages from one pdf to another pdf
  Dim i As Integer
  For i = 0 To documentText.Pages.Count-1
  documentImages.Pages.Add(documentText.Pages(i))
  Next
 
  ' Save merged document    
  documentImages.Save(“MergeDocument.pdf”, True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       Source Code