Page.show_pdf_page() function alternative/work around #1582
Replies: 4 comments
-
The simplest thing to do surely is paths = [p for p in page.get_drawings() if p["rect"] in clip] Done. |
Beta Was this translation helpful? Give feedback.
-
If you however had in mind to include the subset of a drawing that is partly contained in the clip (and some parts outside) ... |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your responses! In my current project, my intention is to extract an area out of a page and export it as a stand-alone pdf file. I want to do some analyses specifically on this area only. Apparently, the show_pdf_page() function also imports all resources outside of the visible clip area, thus get_drawing() outputs things I don't need. Do you have any recommendation to work around it? Thank you! |
Beta Was this translation helpful? Give feedback.
-
If you set a page's Other than mentioned above I have no advice. This is BTW the reason why I detest introducing a clip parameter: (1) the above one-line is too trivial to make a big deal out of it, and (2) it does not work like the clip parameter of other methods (pixmaps, text extractions,...): there, a precise cut-out of the clip happens, whereas a drawing cannot be partially contained - it is either in or out completely. Well, it seems that if you make an SVG image from a page with modified cropbox, the results may better. Haven't checked how far this algorithm goes though. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I am trying to find drawings inside a specific area (clip) of a page in a similar manner to Page.get_text(). However, both Page.get_drawings() and Page.get_cdrawings() do not provide that functionality out of the box.
I wonder if there is a way to work around this issue. If possible, why don't you add a clip parameter inside the Page.get_drawings() and Page.get_cdrawings()?
One way I considered using to work around this problem is to use Document.show_pdf_page(..., clip = ). But as being said in the documentation, all resources "will be imported ... even if they are not contained in the visible area given by clip." Thus, Page.get_cdrawings() still won't work the way I want.
References:
Thank you for your help!
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions