Replies: 1 comment 1 reply
-
@jesuslop Regarding the coordinate system for PyMuPDF maybe this helps? https://pymupdf.readthedocs.io/en/latest/app3.html#coordinates |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have an e-ink reader with stylus to sketch notes and diagrams that I get as pdf. Now am writing something to convert the pds to SVG that I can paste in a note-taking app. It's very pleasant that pymupdf does the heavy lifting of conversion. Thanks! I attach here what I have. All this prologue is to ask about using coordinate systems in pymupdf. I wrote a first version of the converter that worked charms and without problems. It exported a whole A4 sized svg version of my pdf. But that has too many white-space around the figure for practical pasting. Next I wanted to implement automatic fit-to-contents. A thing that works is chaning the media-box of the pdf before exporting the svg. The root of my question is that in the rectrangle that I'm feeding to Page.set_mediabox() the y-coordinate seems to be upside-down!
At some point I have this code
that actually works OK. But I don't understand why I cannot just feed
rect
toset_mediabox
(instead offixed_rect
(a fix I found only empirically).Maybe it is a bug, or maybe I don't understand something about pymupdf.
My work-around solves my case, I'm reporting this for others' benefit.
py_pdf2svg_converter.py.txt
Blank Portrait_20241106.pdf
Beta Was this translation helpful? Give feedback.
All reactions