on-internet
← Community

Paste a PDF image with the correct width and height and position to an SVG file in Python using fitz

Stack Overflow ·

I am trying to convert a PDF file to SVG with correct formatting. I am using the fitz pymupdf library. The text is formatted correctly, but I can’t adjust the image. This is my first time working with PDF or SVG. This is the code: import fitz # PyMuPDF import base64 import zipfile def pdf_to_svg_with_text_and_images(pdf_path, output_zip_path): document = fitz.open(pdf_path) num_pages = len(document) with zipfile.ZipFile(output_zip_path, 'w') as zipf: for page_index in range(num_pages): page = document.load_page(page_index) svg_header = '''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PU

Comments

Sign in or sign up to comment and upvote.

No comments yet.