-
| I apologize in advance because, as a new PyMuPDF user, I'm probably touching on a topic that has already been covered here, but I don't have the background. Simple question, if I have an SVG (ECC200 Datamatrix) that was created by a library in a running process and is available in the memory, how can I place the SVG on a page? Here's an example: Of course I tried to put the ECC200 Datamatrix modules together with "draw_rect", which worked, but it massively reduced performance. I have to process 250,000 pages, so that's not the solution. Can anyone give me an idea how to solve this? | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
| Try this approach: 
 # open SVG source as a (1-page) PyMuPDF Document:
svg_doc = pymupdf.open("svg", svg_data.encode())  # use the bytes version of svg_data
# convert this to a PDF document
source_data = svg_doc.convert_to_pdf()
source = pymupdf.open("pdf", source_data)
# insert source page into the target rect
page.show_pdf_page(rect, source, 0) | 
Beta Was this translation helpful? Give feedback.
Try this approach:
Documentpage.show_pdf_page(rect, source, 0)to place it inside the desired rectangle of the target page.