SathvikGanta's picture
Create svg_to_pdf.py
320fd56 verified
raw
history blame
471 Bytes
import cairosvg
def convert_svg_to_pdf(svg_path, pdf_path):
"""
Converts an SVG file to a PDF while preserving vector data.
Args:
svg_path (str): Path to the input SVG file.
pdf_path (str): Path to save the output PDF file.
"""
try:
cairosvg.svg2pdf(url=svg_path, write_to=pdf_path)
print(f"Successfully converted SVG to PDF: {pdf_path}")
except Exception as e:
print(f"Error converting SVG to PDF: {e}")