XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Convert PDF to SVG
  |  
Home ›› XDoc.PDF ›› C# PDF: Convert PDF to SVG

C#.NET PDF SDK - Convert PDF to SVG in C#.NET


C# Programming Language to Render & Convert PDF to SVG Using C#.NET XDoc.PDF Converter Control




Best C#.NET PDF converter control for converting adobe PDF to SVG file in Visual Studio .NET project


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Written in managed Visual C# code and compatible with .NET Framework 2.0 or above


100% clean .NET solution for PDF to SVG conversion using .NET-compliant C# language


Easily define a PDF page from multi-page PDF document and convert it to SVG file using C#


Instantly convert all PDF document pages to SVG image files in C#.NET class application


Perform high-fidelity PDF to SVG conversion in both ASP.NET web and WinForms applications


Support converting PDF document to SVG image within C#.NET project without quality loss


C# sample code for quick integration in .NET framework program for exporting PDF from SVG


In some situations, it is quite necessary to convert PDF document into SVG image format. Here is a brief introduction to SVG image. SVG, short for scalable vector graphics, is a XML-based file format used to depict two-dimensional vector graphics. As SVG images are defined in XML text lines, they can be easily searched, indexed, scripted, and supported by most of the up to date web browsers. Therefore, in C#.NET web document viewing applications, PDF is often rendered and converted to SVG image for high fidelity viewing.



C#.NET PDF DLLs and Demo Code: Convert PDF to SVG in C#.NET

Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.


This C# sample code describe how to convert PDF to SVG in .NET project.



        #region pdf to svg (one page)
        internal static void convertPdfPageToSvg()
        {
            String inputFilePath = @"";
            String outputDirectory = @"";
            PDFDocument doc = new PDFDocument(inputFilePath);
            int pageIdx = 0; //first page
            BasePage page = doc.GetPage(pageIdx);
            page.ConvertToVectorImage(ContextType.SVG, outputDirectory, "0", RelativeType.SVG);
        }
        #endregion

        #region pdf to svg (all page)
        internal static void convertPdfToSvg()
        {
            String inputFilePath = @"";
            String outputDirectory = @"";
            PDFDocument doc = new PDFDocument(inputFilePath);
            doc.ConvertToVectorImages(ContextType.SVG, outputDirectory, "fileName", RelativeType.SVG);
        }
        #endregion




C# convert two or multiple pdf files to svg (batch convert)





        #region pdf to svg (batch files and single tread)
        internal static void pdfFilesToSvg()
        {
            String inputDirectory = @"C:\input\";
            String outputDirectory = @"C:\output\";
            String[] files = Directory.GetFiles(inputDirectory, "*.pdf");
            foreach (String filePath in files)
            {
                int startIdx = filePath.LastIndexOf("\\");
                int endIdx = filePath.LastIndexOf(".");
                String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
                PDFDocument doc = new PDFDocument(filePath);
                doc.ConvertToVectorImages(ContextType.SVG, outputDirectory, docName, RelativeType.SVG);
            }
        }
        #endregion




.NET Class Namespace Required



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


  RasterEdge.Imaging.SVG.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;





public override void ConvertToVectorImages(ContextType targetType, String directory, String fileName, RelativeType type)

Description:
     Convert to html/svg files and save it on the disk.

Parameters: