SathvikGanta
commited on
Commit
•
320fd56
1
Parent(s):
3dab85e
Create svg_to_pdf.py
Browse files- svg_to_pdf.py +15 -0
svg_to_pdf.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cairosvg
|
2 |
+
|
3 |
+
def convert_svg_to_pdf(svg_path, pdf_path):
|
4 |
+
"""
|
5 |
+
Converts an SVG file to a PDF while preserving vector data.
|
6 |
+
|
7 |
+
Args:
|
8 |
+
svg_path (str): Path to the input SVG file.
|
9 |
+
pdf_path (str): Path to save the output PDF file.
|
10 |
+
"""
|
11 |
+
try:
|
12 |
+
cairosvg.svg2pdf(url=svg_path, write_to=pdf_path)
|
13 |
+
print(f"Successfully converted SVG to PDF: {pdf_path}")
|
14 |
+
except Exception as e:
|
15 |
+
print(f"Error converting SVG to PDF: {e}")
|