Before using show_pdf_page, clean_page resulted in loss of content. #3359
-
Rearranged the problem and wrote the test case:.
test code:
mt_03_22318er.pdf a whole test case: Can you help me, this problem has been bothering me for a long time, have not been able to find the most appropriate way to ensure that all pdf can be displayed properly page and annotation coordinates are also normal! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Did you communicate with @robinwatts about this already on Discord? |
Beta Was this translation helpful? Give feedback.
-
Found the problem! import fitz
def test():
"""
clean_contents 后导致内容丢失,但是通过mac的 preview.app 可以查看
"""
files = ["mt_03_22318er_0_806.pdf", "丢失大量内容401-020605-00.pdf"]
rect = [0, 0, 200, 300]
target_doc = fitz.open()
for file in files:
doc = fitz.open(file)
for page in doc:
page.clean_contents(sanitize=0)
page.insert_image(rect, filename="nur-ruhig.jpg")
page.draw_rect(rect, color=(1, 0, 0))
new_page = target_doc.new_page(width=842, height=595)
new_page.show_pdf_page(new_page.rect, doc, page.number)
doc.close()
target_doc.save("x.pdf")
target_doc.close() |
Beta Was this translation helpful? Give feedback.
-
Almighty @JorjMcKie , please help me! There's nothing I can do. |
Beta Was this translation helpful? Give feedback.
You have to wait for the new version which fixes a number of things.
Most importantly, you will no longer have to use
clean_contents()
.