pymupdf / PyMuPDF

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
https://pymupdf.readthedocs.io
GNU Affero General Public License v3.0
4.52k stars 446 forks source link

Small size after apply fitz.TOOLS.set_small_glyph_heights(True) #3509

Closed Muhammadraafat1 closed 1 month ago

Muhammadraafat1 commented 1 month ago

Description of the bug

I was have a issue "After applying redactions with Page.add_redact_annot() some text disappears" but I applied set_small_glyph_heights and it works well, but the fontsize became small even I determined it by 20 and it's not effected

for example: image

image

How to reproduce the bug

``

for page in doc:
        fitz.TOOLS.set_small_glyph_heights(True)
        for word , replace in `replacements.items():`
            wlist = page.search_for(word)
            for rect in wlist:
                redaction = page.add_redact_annot(
                    rect,
                    text=replace,
                    align=fitz.TEXT_ALIGN_CENTER,
                    `fontsize=20`
                )
        page.apply_redactions()
    doc.save(output_pdf)

``

PyMuPDF version

1.24.4

Operating system

Windows

Python version

3.12

JorjMcKie commented 1 month ago

The fontsize will be automatically adjusted to smaller values until the full text string fits into the redaction (!) rectangle. If you reduced the redaction rectangle height, then this is what happens.

Muhammadraafat1 commented 1 month ago

@JorjMcKie There is no way to make customization to keep fontsize as the font of original text?