ASP.NET Core PDF Viewer Control
How to view a new merged PDF from multiple existing PDF files in ASP.NET MVC PDF Viewer control using C#?

How to merge multiple files into one PDF file, and open, view, edit it in web browser using C# ASP.NET PDF Viewer control for Azure.

Open, read, view and comment a new merged PDF from multiple files in ASP.NET using C# is very simple. EdgePDF provides a simple C# demo code to accomplish the job.

  • Create a new combined PDF from multiple PDF files, or other file formats, such as Word, Excel, PowerPoint, Tiff, JPG, PNG images
  • Read, view, edit newly merged PDF file in web browser

How to view a merged PDF file programmatically in using C#

  1. Download EdgePDF PDF viewer web control
  2. Install EdgePDF demo project in IIS
  3. Follow step by step tutorial


To run the following tutorial successfully, we need the following setup ready.

  1. For ASP.NET Core web app: Setup EdgePDF
  2. For ASP.NET Core MVC web app: Setup EdgePDF
  3. For ASP.NET (.net framework): Setup EdgePDF on IIS
  4. Several demo PDF files in folder C:\temp\merge\

How to read, view, a merged PDF from two PDF files online in ASP.NET C#?

The following steps and C# source code will help to setup a demo ASP.NET project, which allows you to read, view a merged PDF file from two PDF documents in web browser using ASP.NET C# code.

After you have completed the following guide, you can open, view a combined PDF file for commenting, editing through url (a sample url http://localhost:56643/?yourtarget1=merge/pdf-1.pdf&yourtarget2=merge/pdf-scanned-1.pdf)

  • For ASP.NET Core web app, open file UserCommandProcessMiddleware.cs from /DemoProjects/EdgePDF for ASP.NET Core/

  • For ASP.NET (.net framework) project, open file UserCommandProcessHandler.ashx from {EdgePDF demo project}/RasterEdge_Resource_Files/

  • Go to method FileProcess()
  • Get two target PDF files' id from url parameter "yourtarget1" and "yourtarget2"
  • Create two new PDFDocument object with target PDF files loaded
  • Get a new PDF document PDFDocument object with two PDF files combined
  • Call method REProcessControl.PageLoadFile() to load merged PDF document into EdgePDF for viewing, annotating, editing

    public override PDFWebDocument FileProcess()
        HttpRequest request = this.Context.Request;

        if (!String.IsNullOrEmpty(request.QueryString["yourtarget1"]) && !String.IsNullOrEmpty(request.QueryString["yourtarget2"]))
            PDFDocument sourceDoc1 = new PDFDocument(@"C:\\temp\" + request.QueryString["yourtarget1"]);
            PDFDocument sourceDoc2 = new PDFDocument(@"C:\\temp\" + request.QueryString["yourtarget2"]);

            PDFDocument[] sourceDocs = new PDFDocument[] {sourceDoc1, sourceDoc2};

            PDFDocument mergedDoc = PDFDocument.CombineDocument(sourceDocs);

            String fileName = "merged.pdf";
            return REProcessControl.PageLoadFile(request, this.Manager, mergedDoc, fileName);
            Logger.Log(">>> Unknown load file mode. Load default file defined in Web.config.", LogType.DEBUG);

            // load default file. defined in Web.config
            return REProcessControl.PageLoadFile(request, this.Manager, "", LoadType.Server);

After complete the ASP.NET MVC web application, you could publish the web application to web server or Azure service app. RasterEdge provides step by step guide at How to deploy ASP.NET MVC PDF viewer web application to Azure?