SVG JPG PDF XML DOC
  Product Family
PDF

Convert PDF to SVG in Python SDK

Export PDF Documents to multiple formats including SVG (Scalable Vector Graphics) two-dimensional vector graphics with Aspose.PDF Cloud Python SDK

Get Started

How to Convert PDF to SVG Using Python SDK

To convert PDF to SVG, we’ll use Aspose.PDF Cloud Python SDK This Cloud SDK assists Python programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Python programming language via Aspose.PDF REST API. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Python SDK. If the python package is hosted on Github, you can install directly from Github:

Installation from Github


     
    pip install git+https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-python.git

Package Manager Console Command


     
    pip install asposepdfcloud
     
     

Steps to Convert PDF to SVG via Python

Aspose.PDF Cloud Python developers can easily load & convert PDF files to SVG in just a few lines of code.

  1. Set Input File Name
  2. Set Output File Name
  3. Create Options Dictionary
  4. Call API Method
  5. Downloads the SVG file for local use

System Requirements

It is easy to get started with Aspose.PDF Cloud Python SDK:

  • Python 2.7 and 3.4+

 

This sample code shows PDF to SVG via Cloud Python SDK Conversion


    from asposepdfcloud import PdfApi, ApiClient
    import shutil
    import os
    import json
    from pathlib import Path
    import logging

    # Configure logging
    logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

    class PdfToSvgConvert:
        """Class for converting from PDF to SVG using Aspose PDF Cloud API."""
        def convert(self):
            """Convert PDF to SVG (zip)."""
            localFolder = "C:\Samples"
            storagePdfName = "sample.pdf"
            storageTempFolder = "TempPdfCloud"
            outputFileName = "output_svg_convert.zip"

            # Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
            self.pdf_api = PdfApi(ApiClient(AppSecret, AppSid))

            if self.pdf_api:
                file_path = localFolder + "/" + storagePdfName
                self.pdf_api.upload_file(os.path.join(storageTempFolder, storagePdfName), file_path)
                    
                opts = { "folder": storageTempFolder }

                try:
                    response = self.pdf_api.put_pdf_in_storage_to_svg(storagePdfName, os.path.join(storageTempFolder, outputFileName), **opts)

                    if response.code == 200:
                        temp_file = self.pdf_api.download_file(storageTempFolder + '/' + outputFileName)
                        local_path = localFolder + '/' + outputFileName
                        shutil.move(temp_file, local_path)
                        logging.info(f"pdf_svg_convert(): PDF successfully converted to SVG: '{outputFileName}'.")
                    else:
                        logging.error(f"pdf_svg_convert(): Failed to convert PDF to SVG. Response code: {response.code}")
                except Exception as e:
                    logging.error(f"pdf_svg_convert(): Error while converting PDF: {e}")
 
  • Other Supported Conversions

    You can also convert PDF into many other file formats including few listed below.

    PDF TO WORD (Microsoft Word DOC & DOCX)
    PDF TO EXCEL (Microsoft Excel)
    EPUB TO PDF (E-book Format)
    PDF TO JPEG (JPEG Image)
    JPEG TO PDF (JPEG Image)
    PDF TO PNG (Portable Network Graphics)
    GIF TO PDF (Graphical Interchange Format)
    BMP TO PDF (Bitmap Image)
    EMF TO PDF (Enhanced Metafile Format)
    PDF TO PPTX (Open XML presentation Format)
    PDF TO MHT (Hyper Text Markup Language)
    PDF TO MHT (MIME HTML web archive file format)
    MHT TO PDF (Hyper Text Markup Language)
    PDF TO XPS (XML Paper Specifications)
    PS To PDF (PostScript vector graphics)
    PDF TO SVG (Scalable Vector Graphics)
    MD to PDF (Markdown)
    PCL to PDF (Printer Command Language)
    PDF TO TeX (LaTeX Output Text)