Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 30, 2025 19:52
Show Gist options
  • Save aspose-com-gists/44970e2a60bc49bc06f568b3f06779ed to your computer and use it in GitHub Desktop.
Save aspose-com-gists/44970e2a60bc49bc06f568b3f06779ed to your computer and use it in GitHub Desktop.
Convert SVG to PDF in Python
import aspose.cad as cad
from aspose.cad.imageoptions import PdfOptions
# Define the path for the working directory and apply Aspose.CAD license.
dataDir = "data"
license = cad.License()
license.set_license("latest.lic")
# Load the source SVG file by calling the load method.
image = cad.Image.load(dataDir+"paths.svg")
# Create an instance of the CadRasterizationOptions class.
cadRasterizationOptions = cad.imageoptions.CadRasterizationOptions()
# Set the page height.
cadRasterizationOptions.page_height = 800.5
# Set the page width.
cadRasterizationOptions.page_width = 800.5
cadRasterizationOptions.zoom = 0.5
cadRasterizationOptions.layers = "Layer"
# Instantiate an instance of the PdfOptions class.
options = PdfOptions()
options.vector_rasterization_options = cadRasterizationOptions
# Invoke the save method to save the file as PDF.
image.save(dataDir+"result.pdf", options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment