Clipped Design Vector Objects Become Visible in New PDF When Redrawing #3977
Unanswered
Danishkhilji
asked this question in
Looking for help
Replies: 1 comment 2 replies
-
@JorjMcKie can you look at this? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I’m working with a PDF that contains vector design objects, some of which are clipped, meaning parts of the design are intentionally hidden in the original PDF. I’m attempting to extract and redraw these objects into a new PDF file.
I’m using the get_drawings() method from PyMuPDF (MuPDF) to extract the vector paths and redraw them. However, when I draw these extracted paths onto the new PDF, the clipped areas that were originally hidden in the source PDF are now visible, and the design doesn’t match the original.
Steps I’m Taking:
I extract vector drawings using the page.get_drawings(extended=True) method.
I then iterate over the paths and redraw them on a new PDF page using the Shape drawing methods (draw_line, draw_quad, draw_rect, etc.).
The problem is that when I do this, the previously clipped areas of the vectors are now visible, which is not the desired result.
Actual Behavior:
The previously clipped portions of the vector objects are now fully visible, resulting in an inaccurate reproduction of the original design.
How can I correctly handle the clipping regions when redrawing the vector objects so that the clipped areas remain hidden in the new PDF?
Any guidance or solutions would be greatly appreciated. Thank you!
here is the code.
`
@app.post("/pdf-parsing")
async def parse_pdf(file: UploadFile = File(...)):
try:
pdf_bytes = await file.read()
`
Beta Was this translation helpful? Give feedback.
All reactions