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}") | |