pymupdf API reference
121 public APIs from pymupdf (pymupdf/pymupdf) — 4 classes, 105 functions, 12 methods. Signatures extracted by static analysis of the actual source.
Repository: pymupdf/pymupdf
| Kind | Count |
|---|---|
| Classes | 4 |
| Functions | 105 |
| Methods | 12 |
API list
func
src.__main__.doc_join(args)Join pages from several PDF documents.
func
src.__main__.embedded_add(args)Insert a new embedded file.
func
src.__main__.embedded_copy(args)Copy embedded files between PDFs.
func
src.__main__.embedded_del(args)Delete an embedded file entry.
func
src.__main__.embedded_get(args)Retrieve contents of an embedded file.
func
src.__main__.embedded_list(args)List embedded files.
func
src.__main__.extract_objects(args)Extract images and / or fonts from a PDF.
func
src.__main__.find_line_index(values:List[int], value:int) -> intFind the right row coordinate.
func
src.__main__.joinligature(lig:str) -> strReturn ligature character for a given pair / triple of characters.
func
src.__main__.main()Define command configurations.
func
src.__main__.make_textline(left, slot, minslot, lchars)Produce the text of one output line.
func
src.__main__.open_file(filename, password, show=False, pdf=True)Open and authenticate a document.
func
src.__main__.print_dict(item)Print a Python dictionary.
func
src.__main__.print_xref(doc, xref)Print an object given by XREF number.
func
src.__main__.recoverpix(doc, item)Return image for a given XREF.
func
src.table.Table.row_has_bold(bbox)Check if a row contains some bold text.
class
src.table.TableFinderGiven a PDF page, find plausible table structures.
class
src.table.TableHeaderPyMuPDF extension containing the identified table header.
class
src.table.WordMapA WordMap maps words->chars.
func
src.table.are_neighbors(r1, r2)Detect whether r1, r2 are neighbors.
func
src.table.is_parallel(p1, p2)Check if line is roughly axis-parallel.
func
src.table.make_chars(page, clip=None)Extract text as "rawdict" to fill CHARS.
func
src.table.obj_to_bbox(obj)Return the bounding box for an object.
func
src.table.page_rotation_set0(page)Nullify page rotation.
func
src.utils.construct_label(style, prefix, pno) -> strConstruct a label based on style, prefix and page number.
func
src.utils.full_ocr(page, dpi, language, flags)Perform OCR for the full page image.
func
src.utils.getColor(name:str) -> tupleRetrieve RGB color in PDF format by name.
func
src.utils.getColorHSV(name:str) -> tupleRetrieve the hue, saturation, value triple of a color name.
func
src.utils.getColorList() -> listReturns a list of upper-case colour names.
func
src.utils.getDestStr(xref:int, ddict:dict) -> strCalculate the PDF action string.
func
src.utils.get_label_pno(pgNo, labels)Return the label for this page number.
func
src.utils.get_sorted_text(page:pymupdf.Page, clip:rect_like=None, flags:OptInt=None, textpage:pymupdf.TextPage=None, tolerance=3) -> strExtract plain text avoiding unacceptable line breaks.
func
src.utils.get_text_blocks(page:pymupdf.Page, clip:rect_like=None, flags:OptInt=None, textpage:pymupdf.TextPage=None, sort:bool=False) -> listReturn the text blocks on a page.
func
src.utils.get_textpage_ocr(page:pymupdf.Page, flags:int=0, language:str='eng', dpi:int=72, full:bool=False, tessdata:str=None) -> pymupdf.TextPageCreate a Textpage from the OCR version of the page.
func
src.utils.integerToLetter(i) -> strReturns letter sequence string for integer i.
func
src.utils.integerToRoman(num:int) -> strReturn roman numeral for an integer.
func
src.utils.line_text(clip, line)Create the string of one text line.
func
src.utils.recover_bbox_quad(line_dir:tuple, span:dict, bbox:tuple) -> pymupdf.QuadCompute the quad located inside the bbox.
func
src.utils.recover_char_quad(line_dir:tuple, span:dict, char:dict) -> pymupdf.QuadRecover the quadrilateral of a text character.
func
src.utils.recover_line_quad(line:dict, spans:list=None) -> pymupdf.QuadCalculate the line quad for 'dict' / 'rawdict' text extractions.
func
src.utils.recover_quad(line_dir:tuple, span:dict) -> pymupdf.QuadRecover the quadrilateral of a text span.
func
src.utils.recover_span_quad(line_dir:tuple, span:dict, chars:list=None) -> pymupdf.QuadCalculate the span quad for 'dict' / 'rawdict' text extractions.
func
src.utils.rule_dict(item)Make a Python dict from a PDF page label rule.
func
src_classic.__main__.doc_join(args)Join pages from several PDF documents.
func
src_classic.__main__.embedded_add(args)Insert a new embedded file.
func
src_classic.__main__.embedded_copy(args)Copy embedded files between PDFs.
func
src_classic.__main__.embedded_del(args)Delete an embedded file entry.
func
src_classic.__main__.embedded_get(args)Retrieve contents of an embedded file.
func
src_classic.__main__.embedded_list(args)List embedded files.
func
src_classic.__main__.find_line_index(values:List[int], value:int) -> intFind the right row coordinate.
func
src_classic.__main__.joinligature(lig:str) -> strReturn ligature character for a given pair / triple of characters.
func
src_classic.__main__.main()Define command configurations.
func
src_classic.__main__.open_file(filename, password, show=False, pdf=True)Open and authenticate a document.
func
src_classic.__main__.print_dict(item)Print a Python dictionary.
func
src_classic.__main__.print_xref(doc, xref)Print an object given by XREF number.
func
src_classic.__main__.recoverpix(doc, item)Return image for a given XREF.
class
src_classic.utils.ShapeCreate a new shape.
method
src_classic.utils.Shape.commit(overlay:bool=True) -> NoneUpdate the page's /Contents object with Shape data.
method
src_classic.utils.Shape.draw_bezier(p1:point_like, p2:point_like, p3:point_like, p4:point_like) -> PointDraw a standard cubic Bezier curve.
method
src_classic.utils.Shape.draw_circle(center:point_like, radius:float) -> PointDraw a circle given its center and radius.
method
src_classic.utils.Shape.draw_curve(p1:point_like, p2:point_like, p3:point_like) -> PointDraw a curve between points using one control point.
method
src_classic.utils.Shape.draw_line(p1:point_like, p2:point_like) -> PointDraw a line between two points.
method
src_classic.utils.Shape.draw_oval(tetra:typing.Union[quad_like, rect_like]) -> PointDraw an ellipse inside a tetrapod.
method
src_classic.utils.Shape.draw_polyline(points:list) -> PointDraw several connected line segments.
method
src_classic.utils.Shape.draw_quad(quad:quad_like) -> PointDraw a Quad.
method
src_classic.utils.Shape.draw_rect(rect:rect_like, *radius=None) -> PointDraw a rectangle.
method
src_classic.utils.Shape.draw_sector(center:point_like, point:point_like, beta:float, fullSector:bool=True) -> PointDraw a circle sector.
method
src_classic.utils.Shape.draw_squiggle(p1:point_like, p2:point_like, breadth=2) -> PointDraw a squiggly line from p1 to p2.
method
src_classic.utils.Shape.draw_zigzag(p1:point_like, p2:point_like, breadth:float=2) -> PointDraw a zig-zagged line from p1 to p2.
func
src_classic.utils.Shape.pixlen(x)Calculate pixel length of x.
func
src_classic.utils.apply_redactions(page:Page, images:int=2) -> boolApply the redaction annotations of the page.
func
src_classic.utils.build_subset(buffer, unc_set, gid_set)Build font subset using fontTools.
func
src_classic.utils.construct_label(style, prefix, pno) -> strConstruct a label based on style, prefix and page number.
func
src_classic.utils.del_toc_item(doc:Document, idx:int) -> NoneDelete TOC / bookmark item by index.
func
src_classic.utils.delete_image(page:Page, xref:int)Delete the image referred to by xef.
func
src_classic.utils.delete_widget(page:Page, widget:Widget) -> WidgetDelete widget from page and return the next one.
func
src_classic.utils.draw_quad(page:Page, quad:quad_like, color:OptSeq=(0,), fill:OptSeq=None, dashes:OptStr=None, width:float=1, lineCap:int=0, lineJoin:int=0, morph:OptSeq=None, overlay:bool=True, stroke_opacity:float=1, fill_opacity:float=1, oc:int=0) -> PointDraw a quadrilateral.
func
src_classic.utils.draw_rect(page:Page, rect:rect_like, color:OptSeq=(0,), fill:OptSeq=None, dashes:OptStr=None, width:float=1, lineCap:int=0, lineJoin:int=0, morph:OptSeq=None, overlay:bool=True, stroke_opacity:float=1, fill_opacity:float=1, oc:int=0, radius=None) -> PointDraw a rectangle.
func
src_classic.utils.getColor(name:str) -> tupleRetrieve RGB color in PDF format by name.
func
src_classic.utils.getColorHSV(name:str) -> tupleRetrieve the hue, saturation, value triple of a color name.
func
src_classic.utils.getColorInfoList() -> listReturns the list of colour name/value tuples used by this module.
func
src_classic.utils.getColorList() -> listReturns a list of just the colour names used by this module.
func
src_classic.utils.getDestStr(xref:int, ddict:dict) -> strCalculate the PDF action string.
func
src_classic.utils.get_area(*args) -> floatCalculate area of rectangle.
func
src_classic.utils.get_char_widths(doc:Document, xref:int, limit:int=256, idx:int=0, fontdict:OptDict=None) -> listGet list of glyph information of a font.
func
src_classic.utils.get_image_info(page:Page, hashes:bool=False, xrefs:bool=False) -> listExtract image information only from a TextPage.
func
src_classic.utils.get_image_rects(page:Page, name, transform=False) -> listReturn list of image positions on a page.
func
src_classic.utils.get_label(page)Return the label for this PDF page.
func
src_classic.utils.get_label_pno(pgNo, labels)Return the label for this page number.
func
src_classic.utils.get_links(page:Page) -> listCreate a list of all links contained in a PDF page.
func
src_classic.utils.get_oc(doc:Document, xref:int) -> intReturn optional content object xref for an image or form xobject.
func
src_classic.utils.get_old_widths(xref)Retrieve old font '/W' and '/DW' values.
func
src_classic.utils.get_pixmap(page:Page, *matrix:matrix_like=Identity, *dpi=None, *colorspace:Colorspace=csRGB, *clip:rect_like=None, *alpha:bool=False, *annots:bool=True) -> PixmapCreate pixmap of page.
func
src_classic.utils.get_text_blocks(page:Page, clip:rect_like=None, flags:OptInt=None, textpage:TextPage=None, sort:bool=False) -> listReturn the text blocks on a page.
func
src_classic.utils.get_toc(doc:Document, simple:bool=True) -> listCreate a table of contents.
func
src_classic.utils.has_annots(doc:Document) -> boolCheck whether there are annotations on any page.
func
src_classic.utils.has_links(doc:Document) -> boolCheck whether there are links on any page.
func
src_classic.utils.insert_link(page:Page, lnk:dict, mark:bool=True) -> NoneInsert a new link for the current page.
func
src_classic.utils.integerToLetter(i) -> strReturns letter sequence string for integer i.
func
src_classic.utils.integerToRoman(num:int) -> strReturn roman numeral for an integer.
func
src_classic.utils.new_page(doc:Document, pno:int=-1, width:float=595, height:float=842) -> PageCreate and return a new page object.
func
src_classic.utils.output_justify(start, line)Justified output of a line.
func
src_classic.utils.recover_bbox_quad(line_dir:tuple, span:dict, bbox:tuple) -> QuadCompute the quad located inside the bbox.
func
src_classic.utils.recover_char_quad(line_dir:tuple, span:dict, char:dict) -> QuadRecover the quadrilateral of a text character.
func
src_classic.utils.recover_line_quad(line:dict, spans:list=None) -> QuadCalculate the line quad for 'dict' / 'rawdict' text extractions.
func
src_classic.utils.recover_quad(line_dir:tuple, span:dict) -> QuadRecover the quadrilateral of a text span.
func
src_classic.utils.recover_span_quad(line_dir:tuple, span:dict, chars:list=None) -> QuadCalculate the span quad for 'dict' / 'rawdict' text extractions.
func
src_classic.utils.remove_hidden(cont_lines)Remove hidden text from a PDF page.
func
src_classic.utils.repl_fontnames(doc)Populate 'font_buffers'.
func
src_classic.utils.replace_image(page:Page, xref:int, *filename=None, *pixmap=None, *stream=None)Replace the image referred to by xref.
func
src_classic.utils.search_for(*args, **kwargs) -> listSearch for a string on a page.
func
src_classic.utils.set_metadata(doc:Document, m:dict) -> NoneUpdate the PDF /Info object.
func
src_classic.utils.set_oc(doc:Document, xref:int, oc:int) -> NoneAttach optional content object to image or form xobject.
func
src_classic.utils.set_ocmd(doc:Document, xref:int=0, ocgs:typing.Union[list, None]=None, policy:OptStr=None, ve:typing.Union[list, None]=None) -> intCreate or update an OCMD object in a PDF document.
func
src_classic.utils.set_toc(doc:Document, toc:list, collapse:int=1) -> intCreate new outline tree (table of contents, TOC).
func
src_classic.utils.set_toc_item(doc:Document, idx:int, dest_dict:OptDict=None, kind:OptInt=None, pno:OptInt=None, uri:OptStr=None, title:OptStr=None, to:point_like=None, filename:OptStr=None, zoom:float=0) -> NoneUpdate TOC item by index.
func
src_classic.utils.show_pdf_page(*args, **kwargs) -> intShow page number 'pno' of PDF 'src' in rectangle 'rect'.
func
src_classic.utils.subset_fonts(doc:Document, verbose:bool=False) -> NoneBuild font subsets of a PDF.
func
src_classic.utils.textlen(x)Return length of a string.
func
src_classic.utils.update_link(page:Page, lnk:dict) -> NoneUpdate a link on the current page.
func
src_classic.utils.write_text(page:Page, **kwargs) -> NoneWrite the text of one or more TextWriter objects.
About this data
These signatures were extracted from the public source of pymupdf/pymupdf
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.