Reference
pdfplumber API index
pdfplumber's official documentation is its README on GitHub. This index lists every public function, method and property with the signature from version 0.11.10, a plain-language summary, and a link to the guide where we show it working.
How the library is organised
pdfplumber.open(path)returns a PDF. Use it as a context manager so the file is closed.pdf.pagesis a list of Page objects. Everything happens on pages: objects, text, tables.- Pages expose objects (
chars,lines,rects,curves,images,annots) and methods that combine them (extract_text(),extract_tables(),search()). crop(),within_bbox()andfilter()return new pages limited to part of the original, with all the same methods.page.to_image()gives a PageImage for drawing what pdfplumber found.
Signatures below are introspected from the installed library; defaults that are hidden behind **kwargs (text and table options) are documented on extract text and table_settings.
Module
pdfplumber.open(path_or_fp, pages=None, laparams=None, password=None, strict_metadata=False, unicode_norm=None, repair=False, gs_path=None, repair_setting='default', raise_unicode_errors=True)function- Open a PDF from a path, file object or bytes; returns a PDF. Takes password, pages, laparams, repair, unicode_norm.
pdfplumber.repair(path_or_fp, outfile=None, password=None, gs_path=None, setting='default')function- Rewrite a damaged PDF with Ghostscript and return the repaired bytes (or write them to outfile).
PDF (from pdfplumber.open)
pdf.pagesproperty- List of Page objects, one per page (only the pages requested with pages= when opening).
pdf.metadataproperty- Document information dictionary: Title, Author, Producer, CreationDate…
pdf.close()method- Close the underlying file. Called automatically by the with-statement.
pdf.charsproperty- All characters from all pages (also lines, rects, curves, images, annots, hyperlinks).
pdf.structure_treeproperty- Logical structure of a tagged PDF as nested dicts (empty if untagged).
pdf.to_json(stream=None, object_types=None, include_attrs=None, exclude_attrs=None, precision=None, indent=None)method- Serialise every object on every page to JSON (also to_csv, to_dict).
Page (pdf.pages[i], also cropped/filtered pages)
page.page_numberproperty- 1-based page number.
page.widthproperty- Page width in points (also height).
page.bboxproperty- (x0, top, x1, bottom) of the page or of the cropped region.
page.mediaboxproperty- Page boxes in top-left coordinates: mediabox, cropbox, trimbox, bleedbox, artbox.
page.rotationproperty- The page's /Rotate value (0, 90, 180, 270).
page.charsproperty- Every character with text, position, font, size and colours.
page.linesproperty- Drawn line segments with positions, width and colour.
page.rectsproperty- Drawn rectangles.
page.curvesproperty- Drawn curves with their points.
page.imagesproperty- Embedded images with their position and source size.
page.annotsproperty- Annotations (links, comments, highlights).
page.hyperlinksproperty- Link annotations with a URI.
page.edgesproperty- Lines plus the sides of rects and curves, as used by the table finder.
page.objectsproperty- Dict of every object list on the page, keyed by type.
page.extract_text(**kwargs)method- Join characters into text. Options: layout, x_tolerance(_ratio), y_tolerance, directions…
page.extract_text_simple(**kwargs)method- Faster text extraction without layout logic.
page.extract_text_lines(strip=True, return_chars=True, **kwargs)method- Text lines with their bounding boxes (and chars).
page.extract_words(**kwargs)method- Words with bounding boxes; options for tolerances, fonts (extra_attrs), punctuation.
page.search(pattern, regex=True, case=True, main_group=0, return_chars=True, return_groups=True, **kwargs)method- Find a string or regex; returns matches with their position and chars.
page.extract_table(table_settings=None)method- Largest table as a list of rows (or None).
page.extract_tables(table_settings=None)method- Every table as a list of row lists.
page.find_table(table_settings=None)method- Largest table as a Table object (or None).
page.find_tables(table_settings=None)method- Every table as Table objects with bbox, cells, rows, columns.
page.debug_tablefinder(table_settings=None)method- The TableFinder with edges, intersections, cells and tables for given settings.
page.crop(bbox, relative=False, strict=True)method- Page restricted to a bbox; objects partly inside are kept and trimmed.
page.within_bbox(bbox, relative=False, strict=True)method- Page restricted to objects entirely inside a bbox.
page.outside_bbox(bbox, relative=False, strict=True)method- Page restricted to objects entirely outside a bbox.
page.filter(test_function)method- Page with only the objects for which a function returns True.
page.dedupe_chars(**kwargs)method- Page without duplicated (overprinted) characters.
page.to_image(resolution=None, width=None, height=None, antialias=False, force_mediabox=False)method- Render the page to a PageImage for visual debugging (resolution, width or height).
page.close()method- Release the page's cached objects to free memory.
page.structure_treeproperty- Structure tree of this page (tagged PDFs).
page.to_json(stream=None, object_types=None, include_attrs=None, exclude_attrs=None, precision=None, indent=None)method- Serialise the page's objects (also to_csv, to_dict).
Table (from find_tables)
table.bboxproperty- (x0, top, x1, bottom) of the table.
table.cellsproperty- List of cell bboxes.
table.rowsproperty- Rows, each with .cells (bboxes or None for spanned cells).
table.columnsproperty- Columns, each with .cells.
table.extract(**kwargs)method- Text of each cell as a list of rows; accepts word-extraction options.
TableFinder (from debug_tablefinder)
finder.edgesproperty- Edges after snapping, joining and filtering.
finder.intersectionsproperty- Dict of intersection points.
finder.cellsproperty- Cell bboxes built from intersections.
finder.tablesproperty- Table objects.
PageImage (from page.to_image)
im.save(dest, format='PNG', quantize=True, colors=256, bits=8, **kwargs)method- Write the image to a file (PNG by default).
im.show()method- Open the image in a viewer (in Jupyter, just display the object).
im.reset()method- Remove all drawings.
im.draw_rects(list_of_rects, fill=(0, 0, 255, 50), stroke=(255, 0, 0, 200), stroke_width=1)method- Draw rectangles (objects or bboxes); also draw_rect, draw_lines, draw_line.
im.draw_circles(list_of_circles, radius=5, fill=(0, 0, 255, 50), stroke=(255, 0, 0, 200))method- Draw circles at points; also draw_circle.
im.draw_vlines(locations, stroke=(255, 0, 0, 200), stroke_width=1)method- Draw vertical lines at x positions; also draw_hlines, draw_vline, draw_hline.
im.outline_chars(stroke=(255, 0, 0, 255), fill=(255, 0, 0, 63), stroke_width=1)method- Outline every character.
im.outline_words(stroke=(255, 0, 0, 200), fill=(0, 0, 255, 50), stroke_width=1, x_tolerance=3, y_tolerance=3)method- Outline every word.
im.debug_tablefinder(table_settings=None)method- Draw the table finder's edges, intersections and cells.
Reference pages
pdfplumber.open()Paths, bytes, URLs, passwords, laparams, repair.PagesIterating, numbering, sizes, boxes, closing.ObjectsEvery property of chars, lines, rects, curves, images, annots.Structure treeTagged PDFs and marked content.Form fieldsRead AcroForm values and checkboxes.Command lineEvery CLI option with real output.ReleasesVersions, dates and what changed.