You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
why the text block in page is not all removed, (the text block in the chart and near the chart), how can I only remove all the text blocks and not impact drawings
#3966
after run the following code, there are some text blocks removed successfull and some text blocks is not cleaned or removed
test_pdf = 'test1.pdf'
doc = pymupdf.open(test_pdf)
page = doc[0]
blocks = page.get_text("dict", sort=True)["blocks"]
txt_blocks = [blk for blk in blocks if blk['type'] == 0]
for blk in txt_blocks:
page.add_redact_annot(blk['bbox'], fill=False)
for line in block.get('lines', []):
for span in line['spans']:
page.add_redact_annot(span['bbox'], fill=False)
page.apply_redactions(images=0, graphics=1, text=0)
doc.subset_fonts(verbose=True)
doc.ez_save(test_pdf.replace('.pdf', '_remove.pdf'))
doc.close()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
test1.pdf
after run the following code, there are some text blocks removed successfull and some text blocks is not cleaned or removed
test_pdf = 'test1.pdf'
doc = pymupdf.open(test_pdf)
page = doc[0]
blocks = page.get_text("dict", sort=True)["blocks"]
txt_blocks = [blk for blk in blocks if blk['type'] == 0]
for blk in txt_blocks:
page.add_redact_annot(blk['bbox'], fill=False)
for line in block.get('lines', []):
for span in line['spans']:
page.add_redact_annot(span['bbox'], fill=False)
page.apply_redactions(images=0, graphics=1, text=0)
doc.subset_fonts(verbose=True)
doc.ez_save(test_pdf.replace('.pdf', '_remove.pdf'))
doc.close()
Beta Was this translation helpful? Give feedback.
All reactions