Guide for C#
Core Document Formats
HTML5 Web Viewer
Additional Features

C# PDF - Create Online PDF Viewer in C#.NET

C# .NET Online Web-based PDF Document Viewer & Reader

Visual C#
Home > .NET Imaging SDK > C# > Create Online PDF Web Viewer
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C#.NET PDF document HTML5 web viewer control from RasterEdge DocImage SDK for .NET is a professional and user-friendly PDF document viewing and processing solution. This online web-based PDF document viewer and reader control can be easily and stably deployed on ASP.NET web server platform, integrated with .NET programming language C#, inserted into any C#.NET web applications.
C#.NET developers can directly run this online web-based PDF document viewer & reader library control with any modern web browser. Then you can use generated online HTML5 PDF document viewer & reader to read, annotate or redact PDF document file in web browsers.
This tutorial article for how to create HTML5 PDF document web viewer and reader using C#.NET is divided into following four parts.
  • Key features of created C#.NET online web PDF document viewer & reader
  • Installation requirement of C#.NET ASP.NET web PDF document viewer control
  • How to create online web PDF document viewer & reader using C#.NET code
  • C#.NET PDF document online web viewer control FAQs
C# HTML5 PDF Viewer & Reader Library Features
  • Modern PDF document viewer control used for ASP.NET web server application
  • Professional PDF document web viewer featured with functions like highlighting & printing
  • View and annotate PDF document in web browser using C#.NET code
  • Instantly generate thumbnail preview using C# PDF web-based viewer & reader
  • View & edit PDF document in Web application using C# without installing other software
  • Use web PDF viewer to rotate, zoom and process PDF document page using C#.NET code
Web PDF Viewer Installation Requirement
In order to make RasterEdge PDF ASP.NET web viewer & reader control run perfectly in your own C#.NET class application, please make sure you have installed all following components into your C#.NET developing environment. Please note that, our test environment of this C#.NET PDF online web viewer & reader control is in Visual Studio 2005.
  • Microsoft Visual Studio 2005/2008/2010
  • .NET Framework 2.0 or greater versions
  • Windows operating system XP or above
How to Create Web PDF Viewer in C#
In this part, you will find step-by-step guidance on how to create a PDF document viewer in ASP.NET web applications.
  1. In Visual Studio 2005, create an ASP.NET web project and type its name "WebFormAnnotationDemo";
  2. Add all .NET Imaging SDK DLLs in package "Bin" folder to your C#.NET project reference;
  3. Copy your licensed .txt file "RasterEdgeLicense.txt" to your created project folder, together with RasterEdge DocImageSDK DLLs;
  4. Copy package folder "RasterEdge_Imaging_Files" and "Demo_Docs" to your created ASP.NET website folder;
  5. Add reference "RasterEdge.css" and "RasterEdge.js" to Visual Studio "Default.aspx" head tag, like:
    <link href="RasterEdge_Imaging_Files/RasterEdge.css" rel="stylesheet" type="text/css"/>
    <script src="RasterEdge_Imaging_Files/RasterEdge.js" type="text/javascript"></script>
  6. Copy package folder "Demo_Docs" to your created website folder.
  7. Add a new Web.Config: right click "Add New Item...", click "Web Configuration File", name it as "Web.config", and click button "Add".
  8. Copy package file "Web.config" content to this created Web.config.
  9. Replace the "<body>" content of created website Default.aspx with corresponding content of the downloaded package Default.aspx. The buttons displayed on web page can be customized (add or delete) through "<div class="re_func_btn"></div>";
  10. In Defaul.aspx, find
    <div id="_tblImgs" class="re_content" style="width:100%" ></div>
    and add the following javascript to create web viewer, like:
    <div id="_tblImgs" class="re_content" style="width:100%" >
    <script type="text/javascript">
  11. In Default.aspx.cs, set "fileUrl" and "SessionId". Then, add "ImageUrl", "DocWidth", "DocHeight", "ThumbWidth", and "ThumbHeight". See as below(code table 1):
  12. In Default.aspx, add the following javascript(refer to code table 2). (Please note the text wrap)
Code table 1:
public partial class _Default : System.Web.UI.Page
public string FileUrl;
public string SessionId;
public float ThumbHieght = 100;
public float ThumbWidth = 80;
public float DocHieght = 640;
public float DocWidth = 819;
protected void Page_Load(object sender, EventArgs e)
this.FileUrl = Server.MapPath("./Demo_Docs/").Replace("\\", "/") + "Sample.pdf";
this.SessionId = Session.SessionID;
Code table 2:
<script type="text/javascript">
//the patameter definde in aspx.cs aslo need in javascript
_fileUrl = "<%=FileUrl%>";
_docWidth = "<%=DocWidth%>" - 17;
_docHeight = "<%=DocHieght%>";
_thumbWidth = "<%=ThumbWidth%>";
_thumbHeight = "<%=ThumbHieght%>";
_rnd = "<%=SessionId%>";
//this parameter can choose the page show type:0-fit width;1-fit height;2- 1:1
to show
_pageSizeType = 1;
//define annotation style
TextAnnoStyle = new AnnoStyle({FillColor: "White", ShowedText: "double click to
, TextColor: "Black", TextFont: "Arial", TextSize: 12, TextStyle :"Italic"});
FreehandAnnoStyle = new AnnoStyle({OutLineColor: "Red", OutLineWidth: 3.0});
HighlightAnnoStyle = new AnnoStyle({FillColor: "Yellow"});
RectangleAnnoStyle = new AnnoStyle({OutLineColor: "Black", OutLineWidth: 3.0});
FilledRectangleAnnoStyle = new AnnoStyle({OutLineColor: "Black", OutLineWidth:
3.0, FillColor: "Black", Transparency: 1});
EllipseAnnoStyle = new AnnoStyle({FillColor: "Orange"});
RubberStampAnnoStyle = new AnnoStyle({OutLineColor: "Tomato", OutLineWidth: 3.0,
FillColor: "Red", ShowedText: "Stamp annotation can show text here", TextColor: "Black",
TextFont: "Arial", TextSize: 12, TextStyle: "Italic"});
PolygonLinesAnnoStyle = new AnnoStyle({OutLineColor: "Red", OutLineWidth: 3.0});
PolygonAnnoStyle = new AnnoStyle({OutLineColor: "OrangeRed", OutLineWidth: 3.0,
FillColor: "OrangeRed"});
LineAnnoStyle = new AnnoStyle({OutLineColor: "Red", OutLineWidth: 3.0});
C# PDF ASP.NET Web Viewer FAQs
Q: Can your C#.NET PDF document web online viewer and reader support searching PDF content based on certain key word?
A: Sorry, the current version of this C#.NET PDF ASP.NET web viewer control doesn't support this function. But we will add the content searching functionality to the upcoming version.
Screenshot of Online PDF Viewer
More Tutorials!
Find more user guides with RasteEdge .NET Image SDK using Visual C# sample codings!

Recommend this to Google+