Visual C#.NET: Read PDF Document

How to read PDF documents using C#.NET
Yiigo.Image for .NET provides advanced PDF viewing and conversion support, allowing developers to load and view any PDF documents and convert them to over 100 formats supported by Yiigo.Image for .NET(word reading & html reading are also supported). Find more PDF viewing information on Yiigo.Imaging for .NET PDF Reading Plugin.
Yiigo.Imaging for .NET PDF Reading Plugin has those following functionalities:
  • Load, view any PDF document from file, IStream and Stream
  • Extract text, font, and other information from PDF document
  • Rasterize PDF to image
  • Convert PDF to other formats
  • Add new page to PDF document
  • Combine a couple of PDF documents
  • Encrypt and decrypt any PDF files
  • Save and print PDF
This document provides comprehensive Visual C#.NET samples for guiding developers to view, print, convert PDF files using Yiigo.Image for.NET. Find more PDF viewing & conversion tutorials on VB.NET PDF Reading, Web Imaging Viewer PDF Reading Support and Read PDF Documents in .NET Winforms.
Read PDF Documents with C#.NET Sample Code

Requirements

Before reading PDF documents in Visual C#.NET, make sure that you have installed.

Start to Read PDF Documents

  • Open and run your Microsoft Visual Studio;
  • Choose either "Visual C# Projects" in "New Project" dialog box;
  • Choose "Windows Application" in the "Templates" List and name it "YiigoImagingPdfReadCsharp";
  • Right-click on the "References" folder, and select "Add Reference..." from the context menu in the "Solution Explorer" window;
  • In the "Add Reference" dialog box, select the ".NET" tab and browse to Yiigo.Imaging.Net.dll library and Yiigo.Imaging.Net.Pdf.Read.dll;
  • Add it to your Visual C# applications;
  • Call Yiigo .NET Image Namespace & Copy those following codes:
using System.IO;
using System.Drawing.Printing;
using Yiigo.Imaging;
using Yiigo.Imaging.Processing;
using Yiigo.Imaging.PdfRead;

// View a PDF
PdfReader pdf = new PdfReader();
RegisteredReaders.Readers.Add(pdf);
myWorkapceViewer.Open("1.pdf");

// Convert to searchable PDF
public void TranslateToPdf(OcrEngine engine, ImageSource images, Stream
outputStream)
{
engine.Translate(images, "application/pdf", outputStream);
}

// Combine a couple of PDF
PdfReader.Combination("output.pdf", "MobyDick.pdf", "Pride and Prejudice.pdf",
"Metamorphosis.pdf");

// Encrypt & decrypt PDF
PdfReader pdf = new PdfReader("plaintext.pdf");
pdf.Save(password, "encrypted.pdf");

try
{
PdfReader pdf = new PdfReader(password, "encrypted.pdf");
pdf.Save("cleartext.pdf");
}
catch (CodecException e)
{
Console.WriteLine("Unable to open pdfument: " + e.Message);
}

// Extract text from PDF
pdf.ExtractText();
pdf.ExtractTextPosition(Single Left, Single Top, Single Width, Single Height);
pdf.SearchText(String Text, int Occurrence, Boolean CaseSensitive, Boolean WholeWords, ref Single Left, ref
Single Top, ref Single Width, ref Single Height);

// Save & print PDF
pdf.SaveToFile(String FilePath);
pdf.SaveToStream(Stream Stream);
pdf.print();
Products
Other Plugins
Image Viewer CoreBarcode PluginPDF Read & WriteTesseract OCR PluginForm Processing PluginJBIG2 CodecJPEG2000 CodecISIS ScannerTwain ScannerDICOM ReaderCAD Scanner