PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2008 VS 2005 CLR 2.0

How To Merge PDF Documents In .NET

Learn to use PDFOne .NET to merge PDF documents.
By V. Subhash

This article is based on a personal experience. No, it's not meant to make you misty-eyed or something. This is just to illustrate how PDFOne .NET can help you accomplish real-life PDF-related tasks. That's it.

Being an hardware enthusiast, I like to read hard copies of ASUS World magazine that our office gets by post. One day, I went to the ASUS website hoping to get a newer copy of the magazine. The site gave me a ZIP download containing not one but several PDF documents!

These PDFs were heavy and opening them individually was not very conducive for casual browsing. I then decided to merge the documents together using one of our PDF tools. Here are the steps for my PDFOne .NET solution.

  1. Open Visual Studio and create a C# Forms application project.

  2. Add reference to PDFOne.dll.
  3. Drop a "File Open Dialog" Windows component ( System.Windows.Forms.OpenFileDialog) on the form.
  4. Drop a button on the form and add this code for the event handler.
    private void button1_Click(object sender, EventArgs e) {
    
      String[] saFiles;
      ArrayList alFiles = new ArrayList();
      PDFDocument doc;
      // Show "File Open" dialog
      openFileDialog1.Filter = "PDF files (*.pdf)|*.pdf";
      openFileDialog1.Multiselect = true;
      openFileDialog1.ShowDialog();
    
      saFiles = openFileDialog1.FileNames;
    
      if (saFiles.Length > 1) {
        // Place selected PDF files in an array list
        foreach (String sFile in saFiles) {
            alFiles.Add(sFile);
        }
    
        doc = new PDFDocument("your license key");
        doc.OpenAfterCreate = true;
    
        // Merge the PDF documents
        doc.Merge(alFiles);
        doc.Save("merged.pdf");
    
        doc.Close();
      }
    
    }
    
  5. Add a Using directive for Gnostice.PDFOne so that the above code compiles.
  6. Run the project.
  7. Click the button to display the "File Open" dialog.
  8. Select PDF documents that need to be merged and click OK to begin the merge operation.

The PDFDocument.Merge() method accepts an array list containing the pathnames of the PDF documents that need to be merged. Calling this method, merges the document into one file. Here is the output I got. Sweet!

---o0O0o---

Our Developer Tools
eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers

PDFOne (for Java™)

A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications.

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

Privacy | Legal | Feedback | Newsletter | Resellers © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).