MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / write_text

Method write_text

src/__init__.py:13173–13222  ·  view source on GitHub ↗

Write the text of one or more pymupdf.TextWriter objects. Args: rect: target rectangle. If None, the union of the text writers is used. writers: one or more pymupdf.TextWriter objects. overlay: put in foreground or background. keep_proportion:

(
            page: 'Page',
            rect=None,
            writers=None,
            overlay=True,
            color=None,
            opacity=None,
            keep_proportion=True,
            rotate=0,
            oc=0,
            )

Source from the content-addressed store, hash-verified

13171 TOOLS._insert_contents(self, append, True)
13172
13173 def write_text(
13174 page: 'Page',
13175 rect=None,
13176 writers=None,
13177 overlay=True,
13178 color=None,
13179 opacity=None,
13180 keep_proportion=True,
13181 rotate=0,
13182 oc=0,
13183 ) -> None:
13184 """Write the text of one or more pymupdf.TextWriter objects.
13185
13186 Args:
13187 rect: target rectangle. If None, the union of the text writers is used.
13188 writers: one or more pymupdf.TextWriter objects.
13189 overlay: put in foreground or background.
13190 keep_proportion: maintain aspect ratio of rectangle sides.
13191 rotate: arbitrary rotation angle.
13192 oc: the xref of an optional content object
13193 """
13194 assert isinstance(page, Page)
13195 if not writers:
13196 raise ValueError("need at least one pymupdf.TextWriter")
13197 if type(writers) is TextWriter:
13198 if rotate == 0 and rect is None:
13199 writers.write_text(page, opacity=opacity, color=color, overlay=overlay)
13200 return None
13201 else:
13202 writers = (writers,)
13203 clip = writers[0].text_rect
13204 textdoc = Document()
13205 tpage = textdoc.new_page(width=page.rect.width, height=page.rect.height)
13206 for writer in writers:
13207 clip |= writer.text_rect
13208 writer.write_text(tpage, opacity=opacity, color=color)
13209 if rect is None:
13210 rect = clip
13211 page.show_pdf_page(
13212 rect,
13213 textdoc,
13214 0,
13215 overlay=overlay,
13216 keep_proportion=keep_proportion,
13217 rotate=rotate,
13218 clip=clip,
13219 oc=oc,
13220 )
13221 textdoc = None
13222 tpage = None
13223
13224 @property
13225 def xref(self):

Callers 2

write_textFunction · 0.45
test_textbox1Function · 0.45

Calls 3

new_pageMethod · 0.95
DocumentClass · 0.85
show_pdf_pageMethod · 0.80

Tested by 1

test_textbox1Function · 0.36