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

Function gettext

src_classic/__main__.py:802–834  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

800
801
802def gettext(args):
803 doc = open_file(args.input, args.password, pdf=False)
804 pagel = get_list(args.pages, doc.page_count + 1)
805 output = args.output
806 if output == None:
807 filename, _ = os.path.splitext(doc.name)
808 output = filename + ".txt"
809 textout = open(output, "wb")
810 flags = TEXT_PRESERVE_LIGATURES | TEXT_PRESERVE_WHITESPACE
811 if args.convert_white:
812 flags ^= TEXT_PRESERVE_WHITESPACE
813 if args.noligatures:
814 flags ^= TEXT_PRESERVE_LIGATURES
815 if args.extra_spaces:
816 flags ^= TEXT_INHIBIT_SPACES
817 func = {
818 "simple": page_simple,
819 "blocks": page_blocksort,
820 "layout": page_layout,
821 }
822 for pno in pagel:
823 page = doc[pno - 1]
824 func[args.mode](
825 page,
826 textout,
827 args.grid,
828 args.fontsize,
829 args.noformfeed,
830 args.skip_empty,
831 flags=flags,
832 )
833
834 textout.close()
835
836
837def main():

Callers

nothing calls this directly

Calls 3

open_fileFunction · 0.70
get_listFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…