How to split and merge PDF in C# and VB.Net?

How to split and merge PDF in C# and VB.Net?

PDF Metamorphosis .Net

.Net assembly which gives API to convert RTF, Text, HTML, DOCX to PDF in .Net and C#.
How to split and merge PDF in C# and VB.Net?

PDF Metamorphosis .Net

How to split and merge PDF in C# and VB.Net?
How to split and merge PDF in C# and VB.Net?

Introduction

Now let's get to know another benefit of the library. PDF Metamorphosis .Net offers great abilities to split and merge PDF documents. To show how PDF Metamorphosis .Net really lessens the burden of coding, assume that you want to merge 3 (three) PDF files into the one in C#:


            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

string[] pdfFiles = {@"c:\1.pdf", @"c:\2.pdf", @"c:\3.pdf"};
p.MergePDFFileArrayToPDFFile(pdfFiles, @"c:\Single.pdf");
          

Let's see another C# example how split PDF file by pages:


            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

string pdfBook = @"d:\Moscow to the End of the Line.pdf";
string pagesFolder = @"d:\My Book pages\";

p.SplitPDFFileToPDFFolder(pdfBook, pagesFolder);
          

Download

To see this functionality firsthand, download the freshest «PDF Metamorphosis .Net» with code examples, 39.6 Mb.

Limitations

PDF Metamorphosis .Net The limitations of the free version are: The trial notice "Created by unlicensed version of PDF Metamorphosis .Net" and the random addition of the word "TRIAL".


Input PDF documents

PDF Metamorphosis .Net processes PDF documents using own PDF class. If you are looking for .NET class (C#) to convert PDF to other formats, see our PDF Focus .Net.


1. Merge PDF documents in memory using C#:

            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            string fodlerWithPdfs = @"d:\My PDFs\";
            string singlePdf = @"d:\Single.pdf";

            string[] pdfFiles = Directory.GetFiles(fodlerWithPdfs, "*.pdf");

            // ArrayList with PDF documents, each element represents the byte array.
            ArrayList pdfDataList = new ArrayList();

            foreach (string pdfFile in pdfFiles)
            {
                pdfDataList.Add(File.ReadAllBytes(pdfFile));
            }

            byte [] singlePdfBytes = p.MergePDFStreamArrayToPDFStream(pdfDataList);

            if (singlePdfBytes != null)
                File.WriteAllBytes(singlePdf, singlePdfBytes);
      
2. Split PDF documents in VB.Net:
        Dim p As New SautinSoft.PdfMetamorphosis()

        Dim pdfBook As String = "d:\The Winter Queen.pdf"
        Dim pagesFolder As String = "d:\My Book pages\"

        p.SplitPDFFileToPDFFolder(pdfBook, pagesFolder)
      

Requirements and Technical Information

Requires .NET Framework 4.0 or higher. Our product is compatible with all .NET languages and supports all Operating Systems where .NET Framework and .NET Core can be used. Note that PDF Metamorphosis .Net is entirely written in managed C#, which makes it absolutely standalone and an independent library.

.Net Framework 4.0 and higher and .Net Core 2.0 and higher

.NET Framework 4.0, 4.5, 4.6.1 and higher.

.NET Standard 2.0

.NET Core 2.0 and higher.


Multi-platform component, runs on:


Our component has proven itself on cloud platforms and services:

  • Microsoft Azure
  • Amazon Web Services (AWS)
  • Google Cloud Platform
  • SharePoint
  • Docker
  • etc.

If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: