[Python] How to remove scale from PDF file using Python

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    Here I have files in PDF which contain line diagrams. I want to extract each line diagram from the PDF and convert it to a single svg file. My issue is each file has margin scale and I want to remove that.

    [​IMG]

    Currently I am using:

    import fitz # PyMuPDF

    doc = fitz.open(pdf_path)
    page = doc[0] # Get the first page (index 0)
    svg_content = page.get_svg_image(matrix=fitz.Matrix(1, 1))


    for converting file to svg, which is working well, but I don't need full PDF canvas file. I want to crop the image and save that image anywhere I want.

    Continue reading...

Compartilhe esta Página