Convert PDF Pages to SVG Images in Python
Import a PDF document and export every page as a separate SVG image with Aspose.Slides for Python via Java.
Convert PDF to SVG in Python
Aspose.Slides for Python via Java can import PDF pages as slides and export each slide as a scalable SVG image. The conversion produces one SVG file per PDF page and does not require Microsoft PowerPoint or a PDF viewer.
Convert PDF to SVG using Python
Create an empty Presentation, remove its default slide, and call addFromPdf to import the PDF pages. Then access each slide through a variable and call writeAsSvgToBytes to create the SVG data.
Python code for converting PDF pages to SVG
presentation = Presentation()
try:
presentation.getSlides().removeAt(0)
presentation.getSlides().addFromPdf("document.pdf")
slide_count = presentation.getSlides().size()
for slide_index in range(slide_count):
slide = presentation.getSlides().get_Item(slide_index)
file_path = f"page-{slide_index + 1}.svg"
svg_data = bytes(slide.writeAsSvgToBytes())
with open(file_path, "wb") as output_file:
output_file.write(svg_data)
finally:
presentation.dispose()
How to convert PDF pages to SVG images in Python
Follow these steps to import a PDF document and export its pages as separate SVG images.
Install Aspose.Slides for Python via Java .
Configure the package and start the Java Virtual Machine in your application.
Import the PDF pages by calling
addFromPdfon the presentation’s slide collection.Access each slide through a variable, call
writeAsSvgToBytes, and write the returned data to an SVG file.
Convert PDF to Other Supported Formats
You can also convert PDF documents to other supported file formats.