PyMuPDF Documentation
- Introduction
- Installation
- Tutorial
- Recipes
- Recipes: Images
- How to Make Images from Document Pages
- How to Increase Image Resolution
- How to Create Partial Pixmaps (Clips)
- How to Zoom a Clip to a GUI Window
- How to Create or Suppress Annotation Images
- How to Extract Images: Non-PDF Documents
- How to Extract Images: PDF Documents
- How to Handle Image Masks
- How to Make one PDF of all your Pictures (or Files)
- How to Create Vector Images
- How to Convert Images
- How to Use Pixmaps: Glueing Images
- How to Use Pixmaps: Making a Fractal
- How to Interface with NumPy
- How to Add Images to a PDF Page
- Recipes: Text
- Recipes: Annotations
- Recipes: Drawing and Graphics
- Recipes: Multiprocessing
- Recipes: General
- How to Open with a Wrong File Extension
- How to Embed or Attach Files
- How to Delete and Re-Arrange Pages
- How to Join PDFs
- How to Add Pages
- How To Dynamically Clean Up Corrupt PDFs
- How to Split Single Pages
- How to Combine Single Pages
- How to Convert Any Document to PDF
- How to Deal with Messages Issued by MuPDF
- How to Deal with PDF Encryption
- Recipes: Common Issues and their Solutions
- Recipes: Low-Level Interfaces
- Recipes: Journalling
- Recipes: Stories
- How to add a line of text with some formatting
- How to use images
- Reading external HTML and CSS for a Story
- How to output database content with Story templates
- How to integrate with existing PDFs
- How to make multi-columned layouts and access fonts from package pymupdf-fonts
- How make a layout which wraps around a predefined “no go area” layout
- How to output a table
- How to create a simple grid layout
- How to generate a Table of Contents
- How to display a list from JSON data
- Using the alternative
Story.write*()functions
- Recipes: Images
- Module fitz
- Classes
- Annot
AnnotAnnot.get_pixmap()Annot.get_text()Annot.get_textbox()Annot.set_info()Annot.set_line_ends()Annot.set_oc()Annot.get_oc()Annot.set_irt_xref()Annot.set_open()Annot.set_popup()Annot.set_opacity()Annot.blendmodeAnnot.set_blendmode()Annot.set_name()Annot.set_rect()Annot.set_rotation()Annot.set_border()Annot.set_flags()Annot.set_colors()Annot.delete_responses()Annot.update()Annot.file_infoAnnot.get_file()Annot.update_file()Annot.get_sound()Annot.opacityAnnot.parentAnnot.rotationAnnot.rectAnnot.nextAnnot.typeAnnot.infoAnnot.flagsAnnot.line_endsAnnot.verticesAnnot.colorsAnnot.xrefAnnot.irt_xrefAnnot.popup_xrefAnnot.has_popupAnnot.is_openAnnot.popup_rectAnnot.border
- Annotation Icons in MuPDF
- Example
- Archive
- Colorspace
- DisplayList
- Document
DocumentDocument.__init__()Document.get_oc()Document.set_oc()Document.get_layers()Document.add_layer()Document.switch_layer()Document.add_ocg()Document.set_ocmd()Document.get_ocmd()Document.get_layer()Document.set_layer()Document.get_ocgs()Document.layer_ui_configs()Document.set_layer_ui_config()Document.authenticate()Document.get_page_numbers()Document.get_page_labels()Document.set_page_labels()Document.make_bookmark()Document.find_bookmark()Document.chapter_page_count()Document.next_location()Document.prev_location()Document.load_page()Document.reload_page()Document.page_cropbox()Document.page_xref()Document.pages()Document.convert_to_pdf()Document.get_toc()Document.xref_get_keys()Document.xref_get_key()Document.xref_set_key()Document.get_page_pixmap()Document.get_page_xobjects()Document.get_page_images()Document.get_page_fonts()Document.get_page_text()Document.layout()Document.select()Document.set_metadata()Document.get_xml_metadata()Document.set_xml_metadata()Document.set_toc()Document.outline_xref()Document.del_toc_item()Document.set_toc_item()Document.can_save_incrementally()Document.scrub()Document.save()Document.ez_save()Document.saveIncr()Document.tobytes()Document.search_page_for()Document.insert_pdf()Document.new_page()Document.insert_page()Document.delete_page()Document.delete_pages()Document.copy_page()Document.fullcopy_page()Document.move_page()Document.need_appearances()Document.get_sigflags()Document.embfile_add()Document.embfile_count()Document.embfile_get()Document.embfile_del()Document.embfile_info()Document.embfile_names()Document.embfile_upd()Document.close()Document.xref_object()Document.pdf_catalog()Document.pdf_trailer()Document.xref_stream()Document.xref_stream_raw()Document.update_object()Document.update_stream()Document.xref_copy()Document.extract_image()Document.extract_font()Document.xref_xml_metadata()Document.has_links()Document.has_annots()Document.subset_fonts()Document.journal_enable()Document.journal_start_op()Document.journal_stop_op()Document.journal_position()Document.journal_op_name()Document.journal_can_do()Document.journal_undo()Document.journal_redo()Document.journal_save()Document.journal_load()Document.save_snapshot()Document.outlineDocument.is_closedDocument.is_dirtyDocument.is_pdfDocument.is_form_pdfDocument.is_reflowableDocument.is_repairedDocument.needs_passDocument.is_encryptedDocument.permissionsDocument.metadataDocument.nameDocument.page_countDocument.chapter_countDocument.last_locationDocument.FormFonts
set_metadata()Exampleset_toc()Demonstrationinsert_pdf()Examples- Other Examples
- DocumentWriter
- Font
- Identity
- IRect
IRectIRect.__init__()IRect.__init__()IRect.__init__()IRect.__init__()IRect.get_area()IRect.intersect()IRect.contains()IRect.intersects()IRect.torect()IRect.morph()IRect.norm()IRect.normalize()IRect.top_leftIRect.tlIRect.top_rightIRect.trIRect.bottom_leftIRect.blIRect.bottom_rightIRect.brIRect.rectIRect.quadIRect.widthIRect.heightIRect.x0IRect.y0IRect.x1IRect.y1IRect.is_infiniteIRect.is_empty
- Link
- linkDest
- Matrix
MatrixMatrix.__init__()Matrix.__init__()Matrix.__init__()Matrix.__init__()Matrix.__init__()Matrix.__init__()Matrix.__init__()Matrix.norm()Matrix.prerotate()Matrix.prescale()Matrix.preshear()Matrix.pretranslate()Matrix.concat()Matrix.invert()Matrix.aMatrix.bMatrix.cMatrix.dMatrix.eMatrix.fMatrix.is_rectilinear
- Examples
- Shifting
- Flipping
- Shearing
- Rotating
- Outline
- Page
- Pixmap
PixmapPixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.__init__()Pixmap.clear_with()Pixmap.tint_with()Pixmap.gamma_with()Pixmap.shrink()Pixmap.pixel()Pixmap.set_pixel()Pixmap.set_rect()Pixmap.set_origin()Pixmap.set_dpi()Pixmap.set_alpha()Pixmap.invert_irect()Pixmap.copy()Pixmap.save()Pixmap.pdfocr_save()Pixmap.pdfocr_tobytes()Pixmap.tobytes()Pixmap.pil_save()Pixmap.pil_tobytes()Pixmap.warp()Pixmap.color_count()Pixmap.color_topusage()Pixmap.alphaPixmap.digestPixmap.colorspacePixmap.stridePixmap.is_monochromePixmap.is_unicolorPixmap.irectPixmap.samplesPixmap.samples_mvPixmap.samples_ptrPixmap.sizePixmap.widthPixmap.wPixmap.heightPixmap.hPixmap.xPixmap.yPixmap.nPixmap.xresPixmap.yresPixmap.interpolate
- Supported Input Image Formats
- Supported Output Image Formats
- Point
- Quad
- Rect
RectRect.__init__()Rect.__init__()Rect.__init__()Rect.__init__()Rect.__init__()Rect.__init__()Rect.__init__()Rect.round()Rect.transform()Rect.intersect()Rect.include_rect()Rect.include_point()Rect.get_area()Rect.contains()Rect.intersects()Rect.torect()Rect.morph()Rect.norm()Rect.normalize()Rect.irectRect.top_leftRect.tlRect.top_rightRect.trRect.bottom_leftRect.blRect.bottom_rightRect.brRect.quadRect.widthRect.heightRect.x0Rect.y0Rect.x1Rect.y1Rect.is_infiniteRect.is_emptyRect.is_valid
- Shape
ShapeShape.__init__()Shape.draw_line()Shape.draw_squiggle()Shape.draw_zigzag()Shape.draw_polyline()Shape.draw_bezier()Shape.draw_oval()Shape.draw_circle()Shape.draw_curve()Shape.draw_sector()Shape.draw_rect()Shape.draw_quad()Shape.finish()Shape.insert_text()Shape.insert_textbox()Shape.commit()Shape.docShape.pageShape.heightShape.widthShape.draw_contShape.text_contShape.rectShape.totalcontShape.lastPoint
- Usage
- Examples
- Common Parameters
- Story
- TextPage
- TextWriter
- Tools
ToolsTools.gen_id()Tools.set_annot_stem()Tools.set_small_glyph_heights()Tools.set_subset_fontnames()Tools.unset_quad_corrections()Tools.store_shrink()Tools.show_aa_level()Tools.set_aa_level()Tools.reset_mupdf_warnings()Tools.mupdf_display_errors()Tools.mupdf_warnings()Tools.fitz_configTools.store_maxsizeTools.store_size
- Example Session
- Widget
WidgetWidget.button_states()Widget.update()Widget.reset()Widget.nextWidget.border_colorWidget.border_styleWidget.border_widthWidget.border_dashesWidget.choice_valuesWidget.field_nameWidget.field_labelWidget.field_valueWidget.field_flagsWidget.field_typeWidget.field_type_stringWidget.fill_colorWidget.button_captionWidget.is_signedWidget.rectWidget.text_colorWidget.text_fontWidget.text_fontsizeWidget.text_maxlenWidget.text_typeWidget.xrefWidget.scriptWidget.script_strokeWidget.script_formatWidget.script_changeWidget.script_calc
- Standard Fonts for Widgets
- Supported Widget Types
- Xml
XmlXml.add_bullet_list()Xml.add_codeblock()Xml.add_description_list()Xml.add_division()Xml.add_header()Xml.add_horizontal_line()Xml.add_image()Xml.add_link()Xml.add_number_list()Xml.add_paragraph()Xml.add_span()Xml.add_subscript()Xml.add_superscript()Xml.add_code()Xml.add_var()Xml.add_samp()Xml.add_kbd()Xml.add_text()Xml.set_align()Xml.set_attribute()Xml.get_attributes()Xml.get_attribute_value()Xml.remove_attribute()Xml.set_bgcolor()Xml.set_bold()Xml.set_color()Xml.set_columns()Xml.set_font()Xml.set_fontsize()Xml.set_id()Xml.set_italic()Xml.set_leading()Xml.set_lineheight()Xml.set_margins()Xml.set_pagebreak_after()Xml.set_pagebreak_before()Xml.set_properties()Xml.add_style()Xml.add_class()Xml.set_text_indent()Xml.append_child()Xml.create_text_node()Xml.create_element()Xml.insert_before()Xml.insert_after()Xml.clone()Xml.remove()Xml.debug()Xml.find()Xml.find_next()Xml.tagnameXml.textXml.is_textXml.first_childXml.last_childXml.nextXml.previousXml.root
- Setting Text properties
- Context Manager support
- Annot
- Operator Algebra for Geometry Objects
- Low Level Functions and Classes
- Functions
paper_size()paper_rect()sRGB_to_pdf()sRGB_to_rgb()glyph_name_to_unicode()unicode_to_glyph_name()adobe_glyph_names()adobe_glyph_unicodes()css_for_pymupdf_font()recover_quad()make_table()planish_line()paper_sizes()fitz_fontdescriptorsTESSDATA_PREFIXpdfcolorget_pdf_now()get_text_length()get_pdf_str()image_profile()ConversionHeader()ConversionTrailer()Document.del_xml_metadata()Document.xml_metadata_xref()Page.run()Page.get_bboxlog()Page.get_texttrace()Page.wrap_contents()Page.is_wrappedPage.get_text_blocks()Page.get_text_words()Page.get_displaylist()Page.get_contents()Page.set_contents()Page.clean_contents()Page.read_contents()Annot.clean_contents()Document.get_char_widths()Document.is_stream()Document.get_new_xref()Document.xref_length()recover_quad()recover_char_quad()recover_span_quad()recover_line_quad()INFINITE_QUAD()INFINITE_RECT()INFINITE_IRECT()EMPTY_QUAD()EMPTY_RECT()EMPTY_IRECT()
- Device
- Working together: DisplayList and TextPage
- Functions
- Glossary
- Constants and Enumerations
- Color Database
- Appendix 1: Details on Text Extraction
- Appendix 2: Considerations on Embedded Files
- Appendix 3: Assorted Technical Information
- Change Log
- Deprecated Names