C # Convert PDF files into SVG files,

Source: Internet
Author: User

C # Convert PDF files into SVG files,

PDF files are widely used in various office sites. PDF files may be converted to other document formats at work. This document describes how to convert a PDF file into an SVG file. Based on different conversion requirements, there are three cases to describe: Convert all pages of PDF to SVG, convert a specified page of PDF to SVG, and convert a PDF to a specified height and width of SVG. The above three situations are described in detail below.

Tools used:Spire. PDF for. NET

Tip:To use this component, you must first download and install it. In the project, note that you must add the reference Spire. PDF. dll file (as shown below)

Original PDF document:

1.Convert PDFConvert all pages to SVG

Using Spire. pdf; namespace example tosvg_pdf {class Program {static void Main (string [] args) {// create a document class object, load sample, saved as an SVG-formatted file named document = new document (); document. loadFromFile (@ "C: \ Users \ Administrator \ Desktop \ sample.pdf"); document. saveToFile ("output. svg ", FileFormat. SVG );}}}

Debug and run the project to generate the document:

2.The specified PDFConvert pages to SVG

Using Spire. pdf; namespace ConvertPDFPagetoSVG_PDF {class Program {static void Main (string [] args) {// instantiate an upload document class object named upload document doc = new upload document (); // load the Pdf file doc. loadFromFile (@ "C: \ Users \ Administrator \ Desktop \ sample.pdf"); // call the SaveToFile method (string filename, int startIndex, int endIndex, FileFormat) save the specified PDF page as SVG doc. saveToFile ("Result. svg ", 1, 2, FileFormat. SVG );}}}

After debugging and running the program, you can view the successfully converted SVG document.

Converted documents:

3. PDFConvert SVG with specified width and height

Using Spire. pdf; namespace into tosvgw.pdf {class Program {static void Main (string [] args) {// create an upload document class object and load the Pdf file into document = new upload document (); document. loadFromFile (@ "C: \ Users \ Administrator \ Desktop \ sample.pdf"); // call the setjavastosvgoptions () method to specify the width and height of the document to be converted to SVG. convertOptions. settosvgoptions (700f, 1000f); // save it to a file, name the document, and set the Save format document. saveToFile ("result. svg ", FileFormat. SVG );}}}

 

The preceding describes how to convert a PDF file to an SVG file. You can select a conversion method based on your office requirements.

If you like it, you are welcome to repost it. (For details, refer to the source)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.