Print
Apr
19

Spire.PDF Supports PDF to XPS and Image now

During the past three months, our Develop Team is devoting themselves to developing new features about conversion from PDF to XPS, XPS to PDF and PDF Image for Spire.PDF, and now, we excitedly announce that New Release version 2.8 of Spire.PDF with these new features are published. Following, we’ll present these new added features of Spire.PDF 2.8 in details.

 

 

PDF to XPS

Spire.PDF 2.8 enables developers to convert PDF document to XPS. After opening a PDF document and invoke SaveToFile method with parameter string fileName,FileFormat of PdfDocument class to convert. Please refer the C# code:

[C#]
            //pdf file
            String file = @"..\..\..\..\..\..\Data\Sample4.pdf";

            //open pdf document
            PdfDocument doc = new PdfDocument(file);

            //convert to xps file.
            doc.SaveToFile("Sample4.xps", FileFormat.XPS);
            doc.Close();

XPS to PDF

Spire.PDF 2.8 enables developers to convert XPS document to PDF. Invoke LoadFromXPS method with parameter string fileName of PdfDocument to load the XPS document and then invoke SaveToFile method with parameter string fileName of PdfDocument class to convert. Please refer the C# code:

[C#]
            //xps file
            String file = @"..\..\..\..\..\..\Data\Sample4.xps";

            //open xps document
            PdfDocument doc = new PdfDocument();
            doc.LoadFromXPS(file);

            //convert to pdf file.
            doc.SaveToFile("Sample4.pdf");
            doc.Close();


PDF to Image

Spire.PDF 2.8 enables developers to convert pages in PDF document as images. The image formats Spire.PDF 2.8 supports include .png, .bmp, .jpeg, .tiff, .gif, .emf etc. After loading PDF document, invoke SaveAsImage method with parameter int pageIndex of PdfDocument to convert PDF pages as image. The following code demonstrates how to save all PDF pages as image in C#.

[C#]
           //pdf file
            String file = @"..\..\..\..\..\..\Data\Sample4.pdf";

            //open pdf document
            PdfDocument doc = new PdfDocument(file);

            //save to images
            for (int i = 0; i < doc.Pages.Count; i++)
            {
                String fileName = String.Format("Sample4-img-{0}.png", i);
                using (Image image = doc.SaveAsImage(i))
                {
                    image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                    System.Diagnostics.Process.Start(fileName);
                }
            }

            doc.Close();



Download Spire.PDF 2.8 here to evaluate new features:

http://www.e-iceblue.com/Download/download-pdf-for-net-now.html

 

Written by Koohji.