Using ASP.NET PDF Viewer Control
How to open, read, display a PDF file in ASP.NET MVC using C#


Load a pdf file from server side file system, database, online file, and view it in EdgePDF









Open, read and view an existing PDF file in ASP.NET using C# is very simple. EdgePDF provides several methods to accomplish the task.

How to read PDF file in asp.net





Running EdgePDF Demo Project in IIS



After you download the latest version of RasterEdge.DocImageSDK, then how to implement the same effect with the online demo? Here, you can do it according to the following steps.



  1. In download package, go to EdgePDF ASP.NET PDF Editor demo project folder "/DemoProjects/EdgePDF Demo Project/"

    Copy all contents in the above folder to the location, where you need run the demo project in IIS. For example: C:\\Sites\EdgePDF\.


  2. Copy corresponding DLL (x86 or x64) in the download package to the "Bin" folder of the demo project.


  3. After adding relative dlls, configure the Web.config :
    • If your IIS server .NET framework is 4.0 or higher, please use the Web.config.
    • If your IIS server .NET framework is 3.5 or earlier version, please copy the content in the Web(for .net3.5 or earlier version).config to Web.config.


  4. After above steps, you can deploy your demo web application to IIS server.
    1. Open Internet Information Services Manager;
    2. Right-click "Sites" and select "Add Web Site";
    3. According to your situation, set the "Site name", and set the "Physical path" to the place where you store EdgePDF demo project. Last, set the "Port" that monitors the application.
    4. Click ok to complete deploy your project;
    5. Grant user "IIS_IUSRS" full control permission to folder "{Demo project}/RasterEdge_Cache", where EdgePDF will generate cache files.


  5. Run the web application






How to load PDF document into EdgePDF ASP.NET PDF Editor



To run the following demo code, please do the following steps:


  1. Create and add the follow sample documents to folder "c:\temp\"
    • pdf-1.pdf
    • tiff-1.tif
    • word-1.docx
    • excel-1.xlsx
    • powerpoint-1.pptx
    • jpeg-1.jpg
    • text-1.txt
  2. Make sure IIS application (User: IIS_IUSRS) has the read and write rights to the folder "temp“, and all files inside.

The following guide will help to setup a demo project, which allows you to open a file (pdf, word, excel, powerpoint, tiff, jpeg, text) located under your server file system "C:/temp/", through url:
http://localhost:9090/?yourtarget=/1.pdf.

Next one will allow you to define a new command in EdgePDF toolbar. And you can save modified pdf file to original file location "C:/temp/1.pdf"

Here are the details:


            else if (!string.IsNullOrEmpty(request.QueryString["yourtarget"]))
            {

                // load file from your target
                String docid = request.QueryString["yourtarget"];                
                if (docid == null) docid = "0";
                byte[] dataBytes = System.IO.File.ReadAllBytes(@"C:\\temp\" + docid);
                String fileName = docid;               
                webDoc = REProcessControl.PageLoadFile(request, this.Manager, dataBytes, fileName);

            }

You can use the "yourtarget" value to id and locate your file from file system or database, and load the file into PDFDocument or BaseDocument object.



  • Now you navigate to "http://localhost/?yourtarget={your file location key, such as '/word-1.docx'}" to open file in EdgePDF editor.
  • You can change http parameter yourterget to other names, like fileid.




Open a PDF from your local file system



Toolbar: File > File Upload > "Upload your PDF file"
Click browser, and select a PDF document from your file system.







Open a PDF from a http url



Toolbar: File > File Upload > "Open an online PDF file"
Input a complete PDF online document url













Next Steps

Download and try EdgePDF - ASP.NET PDF Editor Control with online support.
See the EdgePDF - ASP.NET PDF Editor Control SDK in action and check how much they can do for you.

Check out the prices. Purchase various licenses for your needs.