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)