Convert Pdf to Other format Using Spire.Pdf

Introduction :

Spire.PDF from E-iceblue is a .NET component that lets you manipulate PDF documents programmatically. Spire.PDF for .NET is a professional .NET library specially designed for developers to create, read, write, convert and print PDF document files from any .NET platform with fast and high-quality performance.

Background :

I got an opportunity from a China-based company E-iceblue, to review one of their products. I selected Spire.Pdf from E-iceblue, which is a .Net component that lets you manipulate PDF documents programmatically.


using Spire.Pdf;
using Spire.Doc.Documents;

Add Reference :

  • Add the following reference.
  • Add the Spire.Pdf,Spire.Doc,Spire.License Dll files to the bin folder.
  • Spire.Pdf contains the PDF conversion libraries.
  • Spire.Doc contains the doc conversion libraries.

Figure 1: Add Reference

Code :


Creating the instance of PdfDocument

PdfDocument document_doc = new PdfDocument();

Load the file location, in this code “spire.pdf” is a pdf file as in the following:

document_doc.LoadFromFile(@"E:\MVC APP\SpireDoc\SpireDoc\spire.pdf");

Convert the PDF file into Document format using “FileFormat.Doc”

document_doc.SaveToFile("Spire.doc", FileFormat.DOC);

Launch the conversion process as in the following:


Examples :

The following converts a PDF to Xps:

//Creating instance of PdfDocument

PdfDocument document = new PdfDocument();

//Loading the File path of pdf file

document.LoadFromFile(@"E:\MVC APP\SpireDoc\SpireDoc\SpireXps.pdf");

//Save Spire.Pdf.PdfDocument object as XPS format.

document.SaveToFile("SpireXps.xps", FileFormat.XPS);

//Launch XPS


OutPut :

Convert Pdf to Xps

OutPut 1

The following converts a PDF to Doc:

//Creating instance of PdfDocument

PdfDocument document_doc = new PdfDocument();

//Loading the File path of pdf file

document_doc.LoadFromFile(@"E:\MVC APP\SpireDoc\SpireDoc\spire.pdf");

//Save Spire.Pdf.PdfDocument object as DOC format.

document_doc.SaveToFile("Spire.doc", FileFormat.DOC);

//Launch Document


OutPut :

Convert Pdf to Doc

Figure 3: Output 2

Important Points :

  • Merge/split PDF documents.
  • Set PDF position, title display, resize, page mode and print scaling, and so on.
  • Protect PDF documents by setting passwords and digital signature.
  • Overlay documents.
  • Decrypt PDF Document.
  • Fast Conversion Process.

Reference :

Published :



One response

  1. I have the following code:

    PdfDocument document = new PdfDocument();


    document.SaveToFile(“SpireXps.xps”, FileFormat.XPS);


    but it gives me the this exception when I run it:
    System.FormatException was unhandled by user code
    Message=Cadeia de caracteres de entrada com formato incorrecto.
    em System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
    em spr᫒.ᜀ(String[] A_0)
    em spr᫒.ᜀ(sprᠺ A_0)
    em Spire.Pdf.PdfDocumentBase.ᜃ(Int32 A_0)
    em sprᶋ.ᜀ(PdfDocumentBase A_0, Int32 A_1)
    em sprᶋ.ᜁ(PdfDocumentBase A_0, Stream A_1)
    em sprᶋ.ᜄ(PdfDocumentBase A_0, Stream A_1)
    em Spire.Pdf.PdfDocumentBase.SaveToXPS(String savefilename)
    em Spire.Pdf.PdfDocumentBase.Save(String fileName, FileFormat fileformat)
    em Spire.Pdf.PdfDocument.SaveToFile(String filename, FileFormat fileFormat)
    em spire.MainWindow..ctor() em C:\Users\Admin-PC\Downloads\spire\spire\MainWindow.xaml.cs:line 47

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: