Pdf document setting in C#.NET
Error processing SSI file

How to Create and Load PDF Document in C#.NET Code


How to Create New PDF in C# language

This C# tutorial shows how to insert meta data to a new Pdf document.

All the available properties are in DocumentInfo object, such as author, description and title.

Second, modify the page size of the new pages.

//Create new pdf document
PdfDocument document = new PdfDocument();

document.DocumentInfo.Author = "test author";
document.DocumentInfo.Description = "test description";
document.DocumentInfo.Title = "test title";

//Insert a new page
PdfPage page = document.Pages.AddPage();

//The default page size is A4
//Customize the page sie directly
page.Size = new Size(800, 1000);
//Or change the value by standard paper size
//page.Size = PaperTypeConverter.ToSize(PaperTypes.A4);


PdfFile pdfFile = new PdfFile();

//Save pdf to file using stream
using (FileStream fs = File.Create("CreateNew.pdf"))
{
    pdfFile.Export(document, fs);
}
//Save pdf to file using byte array
//File.WriteAllBytes("CreateNew.pdf", pdfFile.Export(document));

How to Load and Read Existed PDF in C# language

C# topic explains how to load and import existing PDF document.

Impoart PDF file form steam (file stream and memory stream), or byte array (most used in ASP.NET application).

PdfFile pdfFile = new PdfFile();
PdfDocument document;

//Read pdf document from stream
using (FileStream fs = File.OpenRead("sample.pdf"))
{
    document = pdfFile.Import(fs);
}
//Read pdf document from byte array
//document = pdfFile.Import(File.ReadAllBytes("sample.pdf"));

//Get page count from existing pdf file
int pageCount = document.Pages.Count;
Console.WriteLine(pageCount);
What iDiTect .NET Document component can do

We provide powerful & profession document & image controls: Create a Word Document From a Template using c# (Mail Merge) Mail Merge is the feature of Document, this guide is to illustrate how works Mail Merge function. The simplest way to convert Excel to PDF in C# .Net learn how to convert Excel Workbook to PDF & Worksheet to PDF file. The best C# HTML to PDF solution HTML to PDF Converter for .NET and C# is a fast method to easily create richly-formatted PDF documents, images from HTML. Convert Word file pages to jpg images using C# Convert Docx Word file into editable images using C# Able to convert multi-page Word document to separate image files by C# programming code. C# winform: insert image to pdf append (TIFF/TIF) images to PDF document in C# class application. This example shows the way of adding and merging images to PDF. How to: Programmatically search for and replace text in Documents This example processes a Word document, to find all the occurrences of a specific piece of text in the document.

More Programming Tutorials
More Programming FAQs