Tech Specs
How-to C#
How-to VB.NET
Guide for C#
Core Document Formats
Get to Start - Create, Load, Save
Additional Features

C# PDF - Create, Load and Save PDF File

Detailed Guide for PDF Document Creating, Loading and Saving in C# Project

Visual C#
Home > .NET Imaging SDK > C# > Create, Load and Save PDF Document

"This online guide content is Out Dated!
    Please get the latest XDoc.PDF C# Developer Guide here.

.NET PDF document processing add-on (RasterEdge.Imaging.PDF.dll) from RasterEdge DocImage SDK for .NET is one of those strongly-featured and mature imaging library assemblies for C# programming, which is designed to help developers implement PDF-related tasks in their C#.NET document imaging applications.
On this page, you will learn C#.NET PDF document processing classes, object, as well as C#.NET APIs and sample codes for PDF document creating, loading and saving. Before using mature functions of .NET PDF Document Processing Control in C# project, you should reference PDF processing dll (RasterEdge.Imaging.PDF.dll) and other necessary assemblies (like RasterEdge.Imaging.Basic) to your C#.NET project.
PDF Programming Classes in C#.NET
Before you move on to how to create, load and save PDF document in Visual C# programs, you may firstly learn PDF programming classes. In all, PDF document assembly provides two PDF document processing classes, which are PDFDocument and PDFPage.
  • PDFDocument: This class refers to PDF document and it contains all document information of PDF file. It is an extension of BaseDocument. C# programmers can use PDFDocument object to do bulk operations like load, save, convert images/document and lookup metadata.
  • PDFPage: This class refers to PDF document page contained in PDFDocument and uses BasePage as prototype. By storing page information, C# programmers can get images or svg file out of PDFPage. Also annotations can be added onto PDFPage and saved in a document file format.
PDF Document Object in C#.NET
In C#.NET PDF Document DLL Library, PDFDocument represents the main structure of a document and the pages it contains. When a PDFDocument object is created, C# developers can easily extract information about pages and other document structures. In the following parts, you will be guided to generate, load and save PDF document in C# application.
How to Create and Load a PDFDocument Object in C#
The examples that follows illustrate how to use different sources to generate a PDFDocument object in Visual C# project.

Create and Load a PDFDocument Object from Stream

PDFDocument doc = new PDFDocument(Stream s);

Create and Load a PDFDocument Object from File Path

PDFDocument doc = new PDFDocument(@"D:\BugList\sample1.pdf");

Create and Load a PDFDocument Object from Image Collection

// related API
public PDFDocument(REImage[] imageSource);
Once you have created a PDF document object, you can use the C# sample code below to get the number of pages of this object.
public int GetPageCount(Stream s)
PDFDocument document = new PDFDocument(s);
return document.GetPageCount();
How to Save PDFDocument to File or Stream in C#
If you have a PDFDocument object and have done modification onto it (for example add annotations to page in the document), you can save it back to a PDF file or stream. And following APIs will be used to achieve PDF document saving in C#.NET project.
void Save(String fileName);
void SaveToStream(Stream stream);
byte[] SaveToBytes();

Recommend this to Google+

RasterEdge.com is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2017 Raster Edge.com