Deprecated Names
The original naming convention for methods and properties has been “camelCase”. Since its creation around 2013, a tremendous increase of functionality has happened in PyMuPDF – and with it a corresponding increase in classes, methods and properties. In too many cases, this has led to non-intuitive, illogical and ugly names, difficult to memorize or guess.
A few versions ago, I therefore decided to shift gears and switch to a “snake_cased” naming standard. This was a major effort, which needed a step-wise approach. I think am done with it now (version 1.18.14).
The following list maps deprecated names to their new versions. For example, property pageCount
became page_count
in the Document class. There also are less obvious name changes, e.g. method getPNGdata
was renamed to tobytes
in the Pixmap class.
Names of classes (camel case) and package-wide constants (the majority is upper case) remain untouched.
Old names will remain available as deprecated aliases through MuPDF version 1.19.0 and be removed in the version that follows it - probably version 1.20.0, but this depends on upstream decisions (MuPDF).
Starting with version 1.19.0, we will issue deprecation warnings on sys.stderr
like Deprecation: 'newPage' removed from class 'Document' after v1.19.0 - use 'new_page'.
when aliased methods are being used. Using a deprecated property will not cause this type of warning.
Starting immediately, all deprecated objects (methods and properties) will show a copy of the original’s docstring, prefixed with the deprecation message, for example:
>>> print(fitz.Document.pageCount.__doc__)
*** Deprecated and removed in version following 1.19.0 - use 'page_count'. ***
Number of pages.
>>> print(fitz.Document.newPage.__doc__)
*** Deprecated and removed in version following 1.19.0 - use 'new_page'. ***
Create and return a new page object.
Args:
pno: (int) insert before this page. Default: after last page.
width: (float) page width in points. Default: 595 (ISO A4 width).
height: (float) page height in points. Default 842 (ISO A4 height).
Returns:
A Page object.
There is a utility script alias-changer.py which can be used to do mass-renames in your scripts. It accepts either a single file or a folder as argument. If a folder is supplied, all its Python files and those of its subfolders are changed. Optionally, backups of the scripts can be taken.
Deprecated names are not separately documented. The following list will help you find the documentation of the original.
Note
This is automatically generated. One or two items refer to yet undocumented methods - please simply ignore them.
_isWrapped – Page.is_wrapped
addCaretAnnot – Page.add_caret_annot()
addCircleAnnot – Page.add_circle_annot()
addFileAnnot – Page.add_file_annot()
addFreetextAnnot – Page.add_freetext_annot()
addHighlightAnnot – Page.add_highlight_annot()
addInkAnnot – Page.add_ink_annot()
addLineAnnot – Page.add_line_annot()
addPolygonAnnot – Page.add_polygon_annot()
addPolylineAnnot – Page.add_polyline_annot()
addRectAnnot – Page.add_rect_annot()
addRedactAnnot – Page.add_redact_annot()
addSquigglyAnnot – Page.add_squiggly_annot()
addStampAnnot – Page.add_stamp_annot()
addStrikeoutAnnot – Page.add_strikeout_annot()
addTextAnnot – Page.add_text_annot()
addUnderlineAnnot – Page.add_underline_annot()
addWidget – Page.add_widget()
chapterCount – Document.chapter_count
chapterPageCount – Document.chapter_page_count()
cleanContents – Page.clean_contents()
clearWith – Pixmap.clear_with()
convertToPDF – Document.convert_to_pdf()
copyPage – Document.copy_page()
copyPixmap – Pixmap.copy()
CropBox – Page.cropbox
CropBoxPosition – Page.cropbox_position
deleteAnnot – Page.delete_annot()
deleteLink – Page.delete_link()
deletePage – Document.delete_page()
deletePageRange – Document.delete_pages()
deleteWidget – Page.delete_widget()
derotationMatrix – Page.derotation_matrix
drawBezier – Page.draw_bezier()
drawBezier – Shape.draw_bezier()
drawCircle – Page.draw_circle()
drawCircle – Shape.draw_circle()
drawCurve – Page.draw_curve()
drawCurve – Shape.draw_curve()
drawLine – Page.draw_line()
drawLine – Shape.draw_line()
drawOval – Page.draw_oval()
drawOval – Shape.draw_oval()
drawPolyline – Page.draw_polyline()
drawPolyline – Shape.draw_polyline()
drawQuad – Page.draw_quad()
drawQuad – Shape.draw_quad()
drawRect – Page.draw_rect()
drawRect – Shape.draw_rect()
drawSector – Page.draw_sector()
drawSector – Shape.draw_sector()
drawSquiggle – Page.draw_squiggle()
drawSquiggle – Shape.draw_squiggle()
drawZigzag – Page.draw_zigzag()
drawZigzag – Shape.draw_zigzag()
embeddedFileAdd – Document.embfile_add()
embeddedFileCount – Document.embfile_count()
embeddedFileDel – Document.embfile_del()
embeddedFileGet – Document.embfile_get()
embeddedFileInfo – Document.embfile_info()
embeddedFileNames – Document.embfile_names()
embeddedFileUpd – Document.embfile_upd()
extractFont – Document.extract_font()
extractImage – Document.extract_image()
fileGet – Annot.get_file()
fileUpd – Annot.update_file()
fillTextbox – TextWriter.fill_textbox()
findBookmark – Document.find_bookmark()
firstAnnot – Page.first_annot
firstLink – Page.first_link
firstWidget – Page.first_widget
fullcopyPage – Document.fullcopy_page()
gammaWith – Pixmap.gamma_with()
getArea – Rect.get_area()
getArea – IRect.get_area()
getCharWidths – Document.get_char_widths()
getContents – Page.get_contents()
getDisplayList – Page.get_displaylist()
getDrawings – Page.get_drawings()
getFontList – Page.get_fonts()
getImageBbox – Page.get_image_bbox()
getImageData – Pixmap.tobytes()
getImageList – Page.get_images()
getLinks – Page.get_links()
getOCGs – Document.get_ocgs()
getPageFontList – Document.get_page_fonts()
getPageImageList – Document.get_page_images()
getPagePixmap – Document.get_page_pixmap()
getPageText – Document.get_page_text()
getPageXObjectList – Document.get_page_xobjects()
getPDFnow – get_pdf_now()
getPDFstr – get_pdf_str()
getPixmap – Page.get_pixmap()
getPixmap – Annot.get_pixmap()
getPixmap – DisplayList.get_pixmap()
getPNGData – Pixmap.tobytes()
getPNGdata – Pixmap.tobytes()
getRectArea – Rect.get_area()
getRectArea – IRect.get_area()
getSigFlags – Document.get_sigflags()
getSVGimage – Page.get_svg_image()
getText – Page.get_text()
getText – Annot.get_text()
getTextBlocks – Page.get_text_blocks()
getTextbox – Page.get_textbox()
getTextbox – Annot.get_textbox()
getTextLength – get_text_length()
getTextPage – Page.get_textpage()
getTextPage –
Annot.get_textpage()
getTextPage – DisplayList.get_textpage()
getTextWords – Page.get_text_words()
getToC – Document.get_toc()
getXmlMetadata – Document.get_xml_metadata()
ImageProperties –
image_properties()
includePoint – Rect.include_point()
includePoint –
IRect.include_point()
includeRect – Rect.include_rect()
includeRect –
IRect.include_rect()
insertFont – Page.insert_font()
insertImage – Page.insert_image()
insertLink – Page.insert_link()
insertPage – Document.insert_page()
insertPDF – Document.insert_pdf()
insertText – Page.insert_text()
insertText – Shape.insert_text()
insertTextbox – Page.insert_textbox()
insertTextbox – Shape.insert_textbox()
invertIRect – Pixmap.invert_irect()
isConvex – Quad.is_convex
isDirty – Document.is_dirty
isEmpty – Rect.is_empty
isEmpty – IRect.is_empty
isEmpty – Quad.is_empty
isFormPDF – Document.is_form_pdf
isInfinite – Rect.is_infinite
isInfinite – IRect.is_infinite
isPDF – Document.is_pdf
isRectangular – Quad.is_rectangular
isRectilinear – Matrix.is_rectilinear
isReflowable – Document.is_reflowable
isRepaired – Document.is_repaired
isStream – Document.is_stream()
lastLocation – Document.last_location
lineEnds – Annot.line_ends
loadAnnot – Page.load_annot()
loadLinks – Page.load_links()
loadPage – Document.load_page()
makeBookmark – Document.make_bookmark()
MediaBox – Page.mediabox
MediaBoxSize – Page.mediabox_size
metadataXML – Document.xref_xml_metadata()
movePage – Document.move_page()
needsPass – Document.needs_pass
newPage – Document.new_page()
newShape – Page.new_shape()
nextLocation – Document.next_location()
pageCount – Document.page_count
pageCropBox – Document.page_cropbox()
pageXref – Document.page_xref()
PaperRect – paper_rect()
PaperSize – paper_size()
paperSizes – paper_sizes
PDFCatalog – Document.pdf_catalog()
PDFTrailer – Document.pdf_trailer()
pillowData – Pixmap.pil_tobytes()
pillowWrite – Pixmap.pil_save()
planishLine – planish_line()
preRotate – Matrix.prerotate()
preScale – Matrix.prescale()
preShear – Matrix.preshear()
preTranslate – Matrix.pretranslate()
previousLocation – Document.prev_location()
readContents – Page.read_contents()
resolveLink –
Document.resolve_link()
rotationMatrix – Page.rotation_matrix
searchFor – Page.search_for()
searchPageFor – Document.search_page_for()
setAlpha – Pixmap.set_alpha()
setBlendMode – Annot.set_blendmode()
setBorder – Annot.set_border()
setColors – Annot.set_colors()
setCropBox – Page.set_cropbox()
setFlags – Annot.set_flags()
setInfo – Annot.set_info()
setLanguage –
Document.set_language()
setLineEnds – Annot.set_line_ends()
setMediaBox – Page.set_mediabox()
setMetadata – Document.set_metadata()
setName – Annot.set_name()
setOC – Annot.set_oc()
setOpacity – Annot.set_opacity()
setOrigin – Pixmap.set_origin()
setPixel – Pixmap.set_pixel()
setRect – Annot.set_rect()
setRect – Pixmap.set_rect()
setResolution – Pixmap.set_dpi()
setRotation – Page.set_rotation()
setToC – Document.set_toc()
setXmlMetadata – Document.set_xml_metadata()
showPDFpage – Page.show_pdf_page()
soundGet – Annot.get_sound()
tintWith – Pixmap.tint_with()
transformationMatrix – Page.transformation_matrix
updateLink – Page.update_link()
updateObject – Document.update_object()
updateStream – Document.update_stream()
wrapContents – Page.wrap_contents()
writeImage – Pixmap.save()
writePNG – Pixmap.save()
writeText – Page.write_text()
writeText – TextWriter.write_text()
xrefLength – Document.xref_length()
xrefObject – Document.xref_object()
xrefStream – Document.xref_stream()
xrefStreamRaw – Document.xref_stream_raw()