Summary
-------
* Python bindings for the MuPDF PDF library.
* A python module called ``mupdf``.
* Generated from the MuPDF C++ API, which is itself generated from the MuPDF C API.
* Provides Python functions that wrap most ``fz_`` and ``pdf_`` functions.
* Provides Python classes that wrap most ``fz_`` and ``pdf_`` structs.
* Class methods provide access to most of the underlying C API functions (except for functions that don't take struct args such as ``fz_strlcpy()``).
* MuPDF's ``setjmp``/``longjmp`` exceptions are converted to Python exceptions.
* Functions and methods do not take ``fz_context`` arguments. (Automatically-generated per-thread contexts are used internally.)
* Wrapper classes automatically handle reference counting of the underlying structs (with internal calls to ``fz_keep_*()`` and ``fz_drop_*()``).
* Support for MuPDF function pointers with SWIG Director classes, allowing MuPDF to call Python callbacks.
* Provides a small number of extensions beyond the basic C API:
* Some generated classes have extra support for iteration.
* Some custom class methods and constructors.
* Simple 'POD' structs have ``__str__()`` methods, for example ``mupdf.Rect`` is represented like: ``(x0=90.51 y0=160.65 x1=501.39 y1=215.6)``.
Example usage
-------------
Minimal Python code that uses the ``mupdf`` module:
::
import mupdf
document = mupdf.Document('foo.pdf')
A simple example Python test script (run by ``scripts/mupdfwrap.py -t``) is:
* ``scripts/mupdfwrap_test.py``
More detailed usage of the Python API can be found in:
* ``scripts/mutool.py``
* ``scripts/mutool_draw.py``
Here is some example code that shows all available information about document's Stext blocks, lines and characters:
::
#!/usr/bin/env python3
import mupdf
def show_stext(document):
'''
Shows all available information about Stext blocks, lines and characters.
'''
for p in range(document.count_pages()):
page = document.load_page(p)
stextpage = mupdf.StextPage(page, mupdf.StextOptions())
for block in stextpage:
block_ = block.m_internal
log(f'block: type={block_.type} bbox={block_.bbox}')
for line in block:
line_ = line.m_internal
log(f' line: wmode={line_.wmode}'
+ f' dir={line_.dir}'
+ f' bbox={line_.bbox}'
)
for char in line:
char_ = char.m_internal
log(f' char: {chr(char_.c)!r} c={char_.c:4} color={char_.color}'
+ f' origin={char_.origin}'
+ f' quad={char_.quad}'
+ f' size={char_.size:6.2f}'
+ f' font=('
+ f'is_mono={char_.font.flags.is_mono}'
+ f' is_bold={char_.font.flags.is_bold}'
+ f' is_italic={char_.font.flags.is_italic}'
+ f' ft_substitute={char_.font.flags.ft_substitute}'
+ f' ft_stretch={char_.font.flags.ft_stretch}'
+ f' fake_bold={char_.font.flags.fake_bold}'
+ f' fake_italic={char_.font.flags.fake_italic}'
+ f' has_opentype={char_.font.flags.has_opentype}'
+ f' invalid_bbox={char_.font.flags.invalid_bbox}'
+ f' name={char_.font.name}'
+ f')'
)
document = mupdf.Document('foo.pdf')
show_stext(document)
More information
----------------
https://mupdf.com/r/C-and-Python-APIs
Raw data
{
"_id": null,
"home_page": "https://mupdf.com/",
"name": "mupdf",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "PDF",
"author": "Artifex Software, Inc.",
"author_email": "support@artifex.com",
"download_url": "https://files.pythonhosted.org/packages/59/bc/efcdf44d3dd6a45f9f731e825fb17788d67ee4795694dc3bf8be9483b3e6/mupdf-1.21.1.20230112.1504.tar.gz",
"platform": null,
"description": "Summary\n-------\n\n* Python bindings for the MuPDF PDF library.\n* A python module called ``mupdf``.\n* Generated from the MuPDF C++ API, which is itself generated from the MuPDF C API.\n* Provides Python functions that wrap most ``fz_`` and ``pdf_`` functions.\n* Provides Python classes that wrap most ``fz_`` and ``pdf_`` structs.\n\n * Class methods provide access to most of the underlying C API functions (except for functions that don't take struct args such as ``fz_strlcpy()``).\n* MuPDF's ``setjmp``/``longjmp`` exceptions are converted to Python exceptions.\n* Functions and methods do not take ``fz_context`` arguments. (Automatically-generated per-thread contexts are used internally.)\n* Wrapper classes automatically handle reference counting of the underlying structs (with internal calls to ``fz_keep_*()`` and ``fz_drop_*()``).\n* Support for MuPDF function pointers with SWIG Director classes, allowing MuPDF to call Python callbacks.\n* Provides a small number of extensions beyond the basic C API:\n\n * Some generated classes have extra support for iteration.\n * Some custom class methods and constructors.\n * Simple 'POD' structs have ``__str__()`` methods, for example ``mupdf.Rect`` is represented like: ``(x0=90.51 y0=160.65 x1=501.39 y1=215.6)``.\n\nExample usage\n-------------\n\nMinimal Python code that uses the ``mupdf`` module:\n\n::\n\n import mupdf\n document = mupdf.Document('foo.pdf')\n\n\nA simple example Python test script (run by ``scripts/mupdfwrap.py -t``) is:\n\n* ``scripts/mupdfwrap_test.py``\n\nMore detailed usage of the Python API can be found in:\n\n* ``scripts/mutool.py``\n* ``scripts/mutool_draw.py``\n\nHere is some example code that shows all available information about document's Stext blocks, lines and characters:\n\n::\n\n #!/usr/bin/env python3\n\n import mupdf\n\n def show_stext(document):\n '''\n Shows all available information about Stext blocks, lines and characters.\n '''\n for p in range(document.count_pages()):\n page = document.load_page(p)\n stextpage = mupdf.StextPage(page, mupdf.StextOptions())\n for block in stextpage:\n block_ = block.m_internal\n log(f'block: type={block_.type} bbox={block_.bbox}')\n for line in block:\n line_ = line.m_internal\n log(f' line: wmode={line_.wmode}'\n + f' dir={line_.dir}'\n + f' bbox={line_.bbox}'\n )\n for char in line:\n char_ = char.m_internal\n log(f' char: {chr(char_.c)!r} c={char_.c:4} color={char_.color}'\n + f' origin={char_.origin}'\n + f' quad={char_.quad}'\n + f' size={char_.size:6.2f}'\n + f' font=('\n + f'is_mono={char_.font.flags.is_mono}'\n + f' is_bold={char_.font.flags.is_bold}'\n + f' is_italic={char_.font.flags.is_italic}'\n + f' ft_substitute={char_.font.flags.ft_substitute}'\n + f' ft_stretch={char_.font.flags.ft_stretch}'\n + f' fake_bold={char_.font.flags.fake_bold}'\n + f' fake_italic={char_.font.flags.fake_italic}'\n + f' has_opentype={char_.font.flags.has_opentype}'\n + f' invalid_bbox={char_.font.flags.invalid_bbox}'\n + f' name={char_.font.name}'\n + f')'\n )\n\n document = mupdf.Document('foo.pdf')\n show_stext(document)\n\nMore information\n----------------\n\nhttps://mupdf.com/r/C-and-Python-APIs\n",
"bugtrack_url": null,
"license": "",
"summary": "Python bindings for MuPDF library.",
"version": "1.21.1.20230112.1504",
"split_keywords": [
"pdf"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "53eb388f3930311b27904665e6cc9d4c542827246d4ffa04fb38ecd04a6c181c",
"md5": "ac90f8c421f79834b05b729bd86e52ae",
"sha256": "90ba9e7e0aa90a4016deb5f16a8998e101bf3e94d575404334d51e6b80758660"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "ac90f8c421f79834b05b729bd86e52ae",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 38434083,
"upload_time": "2023-01-12T16:18:22",
"upload_time_iso_8601": "2023-01-12T16:18:22.552596Z",
"url": "https://files.pythonhosted.org/packages/53/eb/388f3930311b27904665e6cc9d4c542827246d4ffa04fb38ecd04a6c181c/mupdf-1.21.1.20230112.1504-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e27e581c79981f6ee12b3fc456c483f99805791535a7b972b0fba1798a379bc",
"md5": "aff551408dd2f3d9d848d08ae8b7161e",
"sha256": "25cad3fc47bf8f1fe8fff9397209364a1d8fbea04d4afa108e6d3dc9ab05bb00"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp310-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "aff551408dd2f3d9d848d08ae8b7161e",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 31139149,
"upload_time": "2023-01-12T16:17:09",
"upload_time_iso_8601": "2023-01-12T16:17:09.848991Z",
"url": "https://files.pythonhosted.org/packages/9e/27/e581c79981f6ee12b3fc456c483f99805791535a7b972b0fba1798a379bc/mupdf-1.21.1.20230112.1504-cp310-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0fb1e3a5d8dd6c1cbc342e509b7a0bd0e43a3694c38877f5f32e4c2c3785d1e4",
"md5": "11a5ddfc5fdbd63c5462ae92bbc441d4",
"sha256": "6ae0af788b6ac0c48585e468cdf7589f197c5e5e0cea5b7b37b5800d77141f12"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "11a5ddfc5fdbd63c5462ae92bbc441d4",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 38434200,
"upload_time": "2023-01-12T16:18:47",
"upload_time_iso_8601": "2023-01-12T16:18:47.211197Z",
"url": "https://files.pythonhosted.org/packages/0f/b1/e3a5d8dd6c1cbc342e509b7a0bd0e43a3694c38877f5f32e4c2c3785d1e4/mupdf-1.21.1.20230112.1504-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7867614751892fc646753ec41ca0e630fbba15a91332989bdce9fde16bb18762",
"md5": "b574ea5e61ce335483dc31514e43f83c",
"sha256": "6c8b8905b9ba49b0ae7f404b63033208b01105b78272652f0f8f218c6d851c26"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp311-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "b574ea5e61ce335483dc31514e43f83c",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 31139040,
"upload_time": "2023-01-12T16:17:32",
"upload_time_iso_8601": "2023-01-12T16:17:32.785015Z",
"url": "https://files.pythonhosted.org/packages/78/67/614751892fc646753ec41ca0e630fbba15a91332989bdce9fde16bb18762/mupdf-1.21.1.20230112.1504-cp311-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e73232716847f33c0c59745110469721b5c1df7bbcc5e61b9614d60e87ae7ba0",
"md5": "7f112e7f95ba2effcbb9bc7c0f3439c8",
"sha256": "68b39c4434a76cf3791ff1546dc30c6b9b64f6a5757e20d1aba35d200fcb1363"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "7f112e7f95ba2effcbb9bc7c0f3439c8",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 38401329,
"upload_time": "2023-01-12T16:19:11",
"upload_time_iso_8601": "2023-01-12T16:19:11.187198Z",
"url": "https://files.pythonhosted.org/packages/e7/32/32716847f33c0c59745110469721b5c1df7bbcc5e61b9614d60e87ae7ba0/mupdf-1.21.1.20230112.1504-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "107d755a4949d81a40ae4e0c94b95e551075177ccaedba129c190aa96f33d48d",
"md5": "ba82f531c663a5ff0db907e9d8a3feff",
"sha256": "440a5319b2bbae8318ecfe6a7cf93b5e16a5076faceb1c7a84b7ac294336cff0"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp37-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "ba82f531c663a5ff0db907e9d8a3feff",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 31135200,
"upload_time": "2023-01-12T16:16:28",
"upload_time_iso_8601": "2023-01-12T16:16:28.459365Z",
"url": "https://files.pythonhosted.org/packages/10/7d/755a4949d81a40ae4e0c94b95e551075177ccaedba129c190aa96f33d48d/mupdf-1.21.1.20230112.1504-cp37-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d0d2cdd3b2001faf4be8806a96d4ce0624e6071f1cf15208fdb561d3871e8db9",
"md5": "6da4e3f6478b4d99f189e2f0fc0c1706",
"sha256": "22dd7bc51adb64e883f986f2d8246bb75533dac56705781641499029bc2706a1"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "6da4e3f6478b4d99f189e2f0fc0c1706",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": null,
"size": 38396211,
"upload_time": "2023-01-12T16:19:40",
"upload_time_iso_8601": "2023-01-12T16:19:40.651524Z",
"url": "https://files.pythonhosted.org/packages/d0/d2/cdd3b2001faf4be8806a96d4ce0624e6071f1cf15208fdb561d3871e8db9/mupdf-1.21.1.20230112.1504-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ede3d51dce7d4107a6bb6f7ee7abe9b9be5a10cef1dea66625eac4b8d27913b",
"md5": "5af6afbdc004b4c605d5cf77a9934c43",
"sha256": "2dfd9c4295e0c0785c1cf90e9349f3b6c4739a8c7dd80a5479fb2247667ab3f0"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp38-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "5af6afbdc004b4c605d5cf77a9934c43",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": null,
"size": 31138702,
"upload_time": "2023-01-12T16:16:48",
"upload_time_iso_8601": "2023-01-12T16:16:48.520745Z",
"url": "https://files.pythonhosted.org/packages/5e/de/3d51dce7d4107a6bb6f7ee7abe9b9be5a10cef1dea66625eac4b8d27913b/mupdf-1.21.1.20230112.1504-cp38-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbc77c8dd4765c969a4aabb63422fede2b36b8c303dbc4a457d97f8a04c923cd",
"md5": "193ed9e29213e733a348e09e115dd046",
"sha256": "f983db05f739be36063e1e32ed3934f6d485bfd8726fbac52d0f29b821461c8f"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "193ed9e29213e733a348e09e115dd046",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 38414640,
"upload_time": "2023-01-12T16:20:07",
"upload_time_iso_8601": "2023-01-12T16:20:07.034556Z",
"url": "https://files.pythonhosted.org/packages/fb/c7/7c8dd4765c969a4aabb63422fede2b36b8c303dbc4a457d97f8a04c923cd/mupdf-1.21.1.20230112.1504-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cfb363b785a555eab74a8dfd93f581b99039e210d289a7665a696bfc18852454",
"md5": "4fb3607913d3b874e8f92c4c27c4ba7d",
"sha256": "a5cc322aefe6f46cfe912843d8d1dd46aa8ea84286c1672a80040ef587fabf3b"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504-cp39-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "4fb3607913d3b874e8f92c4c27c4ba7d",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 31138993,
"upload_time": "2023-01-12T16:17:58",
"upload_time_iso_8601": "2023-01-12T16:17:58.267522Z",
"url": "https://files.pythonhosted.org/packages/cf/b3/63b785a555eab74a8dfd93f581b99039e210d289a7665a696bfc18852454/mupdf-1.21.1.20230112.1504-cp39-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "59bcefcdf44d3dd6a45f9f731e825fb17788d67ee4795694dc3bf8be9483b3e6",
"md5": "6352f8198b767b300126bfa1f2c18a93",
"sha256": "aa581b73df3f23c37ce8965155f549f3f87ae264c00ead68406579157612cca6"
},
"downloads": -1,
"filename": "mupdf-1.21.1.20230112.1504.tar.gz",
"has_sig": false,
"md5_digest": "6352f8198b767b300126bfa1f2c18a93",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 83144204,
"upload_time": "2023-01-12T16:21:01",
"upload_time_iso_8601": "2023-01-12T16:21:01.803154Z",
"url": "https://files.pythonhosted.org/packages/59/bc/efcdf44d3dd6a45f9f731e825fb17788d67ee4795694dc3bf8be9483b3e6/mupdf-1.21.1.20230112.1504.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-12 16:21:01",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "mupdf"
}