id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
21,300 | fitz___init__.py | pymupdf_PyMuPDF/src/fitz___init__.py | # pylint: disable=wildcard-import,unused-import,unused-wildcard-import
from pymupdf import *
from pymupdf import _as_fz_document
from pymupdf import _as_fz_page
from pymupdf import _as_pdf_document
from pymupdf import _as_pdf_page
from pymupdf import _log_items
from pymupdf import _log_items_active
from pymupdf import ... | 397 | Python | .py | 11 | 35.090909 | 70 | 0.818653 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,301 | _apply_pages.py | pymupdf_PyMuPDF/src/_apply_pages.py | import multiprocessing
import os
import time
import pymupdf
# Support for concurrent processing of document pages.
#
class _worker_State:
pass
_worker_state = _worker_State()
def _worker_init(
path,
initfn,
initfn_args,
initfn_kwargs,
pagefn,
pagefn_args,
... | 7,569 | Python | .py | 225 | 21.866667 | 120 | 0.509275 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,302 | conf.py | pymupdf_PyMuPDF/docs/conf.py | # -*- coding: utf-8 -*-
#
import re
import sys
import os
import datetime
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path... | 8,979 | Python | .py | 207 | 41.449275 | 91 | 0.721048 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,303 | quickfox-image-no-go.py | pymupdf_PyMuPDF/docs/samples/quickfox-image-no-go.py | """
This is a demo script using PyMuPDF's Story class to output text as a PDF with
a two-column page layout.
The script demonstrates the following features:
* Layout text around images of an existing ("target") PDF.
* Based on a few global parameters, areas on each page are identified, that
can be used to rec... | 7,719 | Python | .py | 156 | 43.865385 | 90 | 0.678224 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,304 | code-printer.py | pymupdf_PyMuPDF/docs/samples/code-printer.py | """
Demo script PyMuPDF Story class
-------------------------------
Read the Python sources in the script directory and create a PDF of all their
source codes.
The following features are included as a specialty:
1. HTML source for pymupdf.Story created via Python API exclusively
2. Separate Story objects for page hea... | 8,752 | Python | .py | 216 | 33.375 | 105 | 0.583441 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,305 | simple-grid.py | pymupdf_PyMuPDF/docs/samples/simple-grid.py | import pymupdf
MEDIABOX = pymupdf.paper_rect("letter") # output page format: Letter
GRIDSPACE = pymupdf.Rect(100, 100, 400, 400)
GRID = pymupdf.make_table(GRIDSPACE, rows=2, cols=2)
CELLS = [GRID[i][j] for i in range(2) for j in range(2)]
text_table = ("A", "B", "C", "D")
writer = pymupdf.DocumentWriter(__file__.repl... | 884 | Python | .py | 22 | 36.090909 | 85 | 0.668998 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,306 | multiprocess-render.py | pymupdf_PyMuPDF/docs/samples/multiprocess-render.py | """
Demonstrate the use of multiprocessing with PyMuPDF.
Depending on the number of CPUs, the document is divided in page ranges.
Each range is then worked on by one process.
The type of work would typically be text extraction or page rendering. Each
process must know where to put its results, because this processing... | 3,243 | Python | .py | 65 | 44.876923 | 80 | 0.69921 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,307 | multiprocess-gui.py | pymupdf_PyMuPDF/docs/samples/multiprocess-gui.py | """
Created on 2019-05-01
@author: yinkaisheng@live.com
@copyright: 2019 yinkaisheng@live.com
@license: GNU AFFERO GPL 3.0
Demonstrate the use of multiprocessing with PyMuPDF
-----------------------------------------------------
This example shows some more advanced use of multiprocessing.
The main process show a Qt ... | 6,215 | Python | .py | 160 | 30.18125 | 195 | 0.620581 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,308 | annotations-ink.py | pymupdf_PyMuPDF/docs/samples/annotations-ink.py | import math
import pymupdf
#------------------------------------------------------------------------------
# preliminary stuff: create function value lists for sine and cosine
#------------------------------------------------------------------------------
w360 = math.pi * 2 # go through full circle
deg = w360 / 360 ... | 1,907 | Python | .py | 37 | 49.648649 | 79 | 0.514745 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,309 | filmfestival-sql.py | pymupdf_PyMuPDF/docs/samples/filmfestival-sql.py | """
This is a demo script for using PyMuPDF with its "Story" feature.
The following aspects are being covered here:
* The script produces a report of films that are stored in an SQL database
* The report format is provided as a HTML template
The SQL database contains two tables:
1. Table "films" which has the column... | 4,797 | Python | .py | 95 | 48.063158 | 78 | 0.634985 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,310 | new-annots.py | pymupdf_PyMuPDF/docs/samples/new-annots.py | # -*- coding: utf-8 -*-
"""
-------------------------------------------------------------------------------
Demo script showing how annotations can be added to a PDF using PyMuPDF.
It contains the following annotation types:
Caret, Text, FreeText, text markers (underline, strike-out, highlight,
squiggle), Circle, Squa... | 4,798 | Python | .py | 140 | 32.385714 | 91 | 0.696622 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,311 | quickfox.py | pymupdf_PyMuPDF/docs/samples/quickfox.py | """
This is a demo script using PyMuPDF's Story class to output text as a PDF with
a two-column page layout.
The script demonstrates the following features:
* How to fill columns or table cells of complex page layouts
* How to embed images
* How to modify existing, given HTML sources for output (text indent, font size... | 3,042 | Python | .py | 72 | 39.625 | 89 | 0.660684 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,312 | json-example.py | pymupdf_PyMuPDF/docs/samples/json-example.py | import pymupdf
import json
my_json = """
[
{
"name" : "Five-storied Pagoda",
"temple" : "Rurikō-ji",
"founded" : "middle Muromachi period, 1442",
"region" : "Yamaguchi, Yamaguchi",
"position" : "34.190181,131.472917"
},
... | 6,789 | Python | .py | 194 | 26.649485 | 72 | 0.44234 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,313 | story-write-stabilized-links.py | pymupdf_PyMuPDF/docs/samples/story-write-stabilized-links.py | """
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized_with_links()`.
`pymupdf.Story.write_stabilized_links()` is similar to
`pymupdf.Story.write_stabilized()` except that it creates a PDF `pymupdf.Document`
that contains PDF links generated from all internal links in the original html.
"""
import textwrap
im... | 2,923 | Python | .py | 73 | 30.369863 | 89 | 0.540628 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,314 | story-write-stabilized.py | pymupdf_PyMuPDF/docs/samples/story-write-stabilized.py | """
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized()`.
`pymupdf.Story.write_stabilized()` is similar to `pymupdf.Story.write()`,
except instead of taking a fixed html document, it does iterative layout
of dynamically-generated html content (provided by a callback) to a
`pymupdf.DocumentWriter`.
For example... | 2,783 | Python | .py | 70 | 30.9 | 76 | 0.567085 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,315 | national-capitals.py | pymupdf_PyMuPDF/docs/samples/national-capitals.py | """
Demo script using (Py-) MuPDF "Story" feature.
The following features are implemented:
* Use of Story "template" feature to provide row content
* Use database access (SQLITE) to fetch row content
* Use ElementPosition feature to locate cell positions on page
* Simulate feature "Table Header Repeat"
* Simulate fea... | 17,442 | Python | .py | 414 | 39.845411 | 102 | 0.704503 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,316 | make-bold.py | pymupdf_PyMuPDF/docs/samples/make-bold.py | """
Problem: Since MuPDF v1.16 a 'Freetext' annotation font is restricted to the
"normal" versions (no bold, no italics) of Times-Roman, Helvetica, Courier.
It is impossible to use PyMuPDF to modify this.
Solution: Using Adobe's JavaScript API, it is possible to manipulate properties
of Freetext annotations. Check out... | 2,818 | Python | .py | 62 | 43.403226 | 83 | 0.725118 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,317 | table01.py | pymupdf_PyMuPDF/docs/samples/table01.py | """
Demo script for basic HTML table support in Story objects
Outputs a table with three columns that fits on one Letter page.
The content of each row is filled via the Story's template mechanism.
Column widths and row heights are automatically computed by MuPDF.
Some styling via a CSS source is also demonstrated:
- ... | 5,790 | Python | .py | 112 | 47.660714 | 840 | 0.689686 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,318 | text-lister.py | pymupdf_PyMuPDF/docs/samples/text-lister.py | import sys
import pymupdf
def flags_decomposer(flags):
"""Make font flags human readable."""
l = []
if flags & 2 ** 0:
l.append("superscript")
if flags & 2 ** 1:
l.append("italic")
if flags & 2 ** 2:
l.append("serifed")
else:
l.append("sans")
if flags & 2 *... | 1,221 | Python | .py | 36 | 26.305556 | 73 | 0.545377 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,319 | story-write.py | pymupdf_PyMuPDF/docs/samples/story-write.py | """
Demo script for PyMuPDF's `Story.write()` method.
This is a way of laying out a story into a PDF document, that avoids the need
to write a loop that calls `story.place()` and `story.draw()`.
Instead just a single function call is required, albeit with a `rectfn()`
callback that returns the rectangles into which t... | 1,638 | Python | .py | 63 | 22.873016 | 84 | 0.644932 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,320 | showpdf-page.py | pymupdf_PyMuPDF/docs/samples/showpdf-page.py | """
Demo of Story class in PyMuPDF
-------------------------------
This script demonstrates how to the results of a pymupdf.Story output can be
placed in a rectangle of an existing (!) PDF page.
"""
import io
import os
import pymupdf
def make_pdf(fileptr, text, rect, font="sans-serif", archive=None):
"""Make a... | 3,201 | Python | .py | 67 | 43.268657 | 177 | 0.639307 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,321 | annotations-freetext.py | pymupdf_PyMuPDF/docs/samples/annotations-freetext.py | # -*- coding: utf-8 -*-
import pymupdf
# some colors
blue = (0,0,1)
green = (0,1,0)
red = (1,0,0)
gold = (1,1,0)
# a new PDF with 1 page
doc = pymupdf.open()
page = doc.new_page()
# 3 rectangles, same size, above each other
r1 = pymupdf.Rect(100,100,200,150)
r2 = r1 + (0,75,0,75)
r3 = r2 + (0,75,0,75)
# the tex... | 767 | Python | .py | 24 | 30.625 | 86 | 0.695238 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,322 | fulltoc.py | pymupdf_PyMuPDF/docs/extensions/fulltoc.py | # -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
# Author: Doug Hellmann <doug.hellmann@dreamhost.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# ... | 3,164 | Python | .py | 84 | 31.607143 | 75 | 0.689172 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,323 | searchrepair.py | pymupdf_PyMuPDF/docs/extensions/searchrepair.py | import os
def modify_search_index(app, exception):
if exception is None: # build succeeded
filename = os.path.join(app.outdir, "searchindex.js")
if os.path.exists(filename):
searchfile = open(filename)
data1 = searchfile.read()
searchfile.close()
... | 729 | Python | .py | 19 | 27.105263 | 62 | 0.542735 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,324 | test_pyodide.yml | pymupdf_PyMuPDF/.github/workflows/test_pyodide.yml | name: Build Pyodide wheel
on:
workflow_dispatch:
inputs:
PYMUPDF_SETUP_MUPDF_BUILD:
description: 'Value for PYMUPDF_SETUP_MUPDF_BUILD, e.g.: git:--branch master https://github.com/ArtifexSoftware/mupdf.git'
type: string
#default: 'git:--branch master https://github.com/Arti... | 1,546 | Python | .py | 44 | 26.681818 | 132 | 0.622962 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,325 | conftest.py | pymupdf_PyMuPDF/tests/conftest.py | import os
import platform
import pymupdf
import pytest
@pytest.fixture(autouse=True)
def wrap(*args, **kwargs):
'''
Check that tests return with empty MuPDF warnings buffer. For example this
detects failure to call fz_close_output() before fz_drop_output(), which
(as of 2024-4-12) generates a warning... | 2,861 | Python | .py | 66 | 34.530303 | 97 | 0.601383 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,326 | test_textextract.py | pymupdf_PyMuPDF/tests/test_textextract.py | """
Extract page text in various formats.
No checks performed - just contribute to code coverage.
"""
import os
import sys
import pymupdf
pymupdfdir = os.path.abspath(f'{__file__}/../..')
scriptdir = f'{pymupdfdir}/tests'
filename = os.path.join(scriptdir, "resources", "symbol-list.pdf")
def test_extract1():
do... | 51,740 | Python | .py | 336 | 144.919643 | 5,155 | 0.758476 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,327 | gentle_compare.py | pymupdf_PyMuPDF/tests/gentle_compare.py | import math
import pymupdf
def gentle_compare(w0, w1):
"""Check lists of "words" extractions for approximate equality.
* both lists must have same length
* word items must contain same word strings
* word rectangles must be approximately equal
"""
tolerance = 1e-3 # maximum (Euclidean) norm... | 1,949 | Python | .py | 48 | 33.895833 | 83 | 0.600528 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,328 | test_cluster_drawings.py | pymupdf_PyMuPDF/tests/test_cluster_drawings.py | import os
import pymupdf
scriptdir = os.path.dirname(__file__)
def test_cluster1():
"""Confirm correct identification of known examples."""
if not hasattr(pymupdf, "mupdf"):
print("Not executing 'test_cluster1' in classic")
return
filename = os.path.join(scriptdir, "resources", "symbol-li... | 1,436 | Python | .py | 40 | 30.725 | 73 | 0.655148 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,329 | test_codespell.py | pymupdf_PyMuPDF/tests/test_codespell.py | import pymupdf
import os
import platform
import shlex
import subprocess
import sys
import textwrap
def test_codespell():
'''
Check rebased Python code with codespell.
'''
if not hasattr(pymupdf, 'mupdf'):
print('Not running codespell with classic implementation.')
return
if p... | 2,242 | Python | .py | 64 | 26.3125 | 84 | 0.598783 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,330 | test_pylint.py | pymupdf_PyMuPDF/tests/test_pylint.py | import pymupdf
import os
import re
import subprocess
import sys
import textwrap
def test_pylint():
if not hasattr(pymupdf, 'mupdf'):
print(f'test_pylint(): Not running with classic implementation.')
return
ignores = ''
ignores += textwrap.dedent(
'''
C... | 7,884 | Python | .py | 129 | 50.713178 | 166 | 0.653098 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,331 | test_linequad.py | pymupdf_PyMuPDF/tests/test_linequad.py | """
Check approx. equality of search quads versus quads recovered from
text extractions.
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "quad-calc-0.pdf")
def test_quadcalc():
text = " angle 327" # search for this text
doc... | 975 | Python | .py | 25 | 35.24 | 69 | 0.683598 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,332 | test_import.py | pymupdf_PyMuPDF/tests/test_import.py | import os
import subprocess
import sys
import textwrap
def test_import():
root = os.path.abspath(f'{__file__}/../../')
p = f'{root}/tests/resources_test_import.py'
with open(p, 'w') as f:
f.write(textwrap.dedent(
'''
from pymupdf.utils import *
from ... | 482 | Python | .py | 16 | 21.5 | 61 | 0.534483 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,333 | test_2791.py | pymupdf_PyMuPDF/tests/test_2791.py | import pymupdf
import gc
import os
import platform
import sys
def merge_pdf(content: bytes, coverpage: bytes):
with pymupdf.Document(stream=coverpage, filetype='pdf') as coverpage_pdf:
with pymupdf.Document(stream=content, filetype='pdf') as content_pdf:
coverpage_pdf.insert_pdf(content_pdf)
... | 3,282 | Python | .py | 80 | 33.075 | 119 | 0.614371 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,334 | test_pixmap.py | pymupdf_PyMuPDF/tests/test_pixmap.py | """
Pixmap tests
* make pixmap of a page and assert bbox size
* make pixmap from a PDF xref and compare with extracted image
* pixmap from file and from binary image and compare
"""
import pymupdf
import os
import platform
import sys
import tempfile
import pytest
import textwrap
scriptdir = os.path.abspath(os.path.d... | 13,375 | Python | .py | 328 | 33.088415 | 192 | 0.617217 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,335 | test_2907.py | pymupdf_PyMuPDF/tests/test_2907.py | import pymupdf
import os.path
import pathlib
def test_2907():
# This test is for a bug in classic 'segfault trying to call clean_contents
# on certain pdfs with python 3.12', which we are not going to fix.
if not hasattr(pymupdf, 'mupdf'):
print('test_2907(): not running on classic because known t... | 818 | Python | .py | 19 | 37.684211 | 79 | 0.678392 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,336 | test_2904.py | pymupdf_PyMuPDF/tests/test_2904.py | import pymupdf
import os
import sys
def test_2904():
print(f'test_2904(): {pymupdf.mupdf_version_tuple=}.')
path = os.path.abspath(f'{__file__}/../../tests/resources/test_2904.pdf')
pdf_docs = pymupdf.open(path)
for page_id, page in enumerate(pdf_docs):
page_imgs = page.get_images()
fo... | 1,661 | Python | .py | 40 | 27.525 | 86 | 0.479554 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,337 | test_linebreaks.py | pymupdf_PyMuPDF/tests/test_linebreaks.py | import pymupdf
import os.path
def test_linebreaks():
"""Test avoidance of linebreaks."""
path = os.path.abspath(f"{__file__}/../../tests/resources/test-linebreaks.pdf")
doc = pymupdf.open(path)
page = doc[0]
tp = page.get_textpage(flags=pymupdf.TEXTFLAGS_WORDS)
word_count = len(page.get_text(... | 558 | Python | .py | 13 | 38.615385 | 83 | 0.691882 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,338 | test_drawings.py | pymupdf_PyMuPDF/tests/test_drawings.py | """
Extract drawings of a PDF page and compare with stored expected result.
"""
import io
import os
import sys
import pprint
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "symbol-list.pdf")
symbols = os.path.join(scriptdir, "resources", "symbols... | 6,746 | Python | .py | 186 | 31.182796 | 87 | 0.638889 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,339 | test_font.py | pymupdf_PyMuPDF/tests/test_font.py | """
Tests for the Font class.
"""
import pymupdf
import os
def test_font1():
text = "PyMuPDF"
font = pymupdf.Font("helv")
assert font.name == "Helvetica"
tl = font.text_length(text, fontsize=20)
cl = font.char_lengths(text, fontsize=20)
assert len(text) == len(cl)
assert abs(sum(cl) - tl) <... | 7,255 | Python | .py | 168 | 33.52381 | 123 | 0.574166 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,340 | test_optional_content.py | pymupdf_PyMuPDF/tests/test_optional_content.py | """
Test of Optional Content code.
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "joined.pdf")
def test_oc1():
"""Arbitrary calls to OC code to get coverage."""
doc = pymupdf.open()
ocg1 = doc.add_ocg("ocg1")
ocg2... | 4,629 | Python | .py | 109 | 37.266055 | 103 | 0.641203 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,341 | test_textbox.py | pymupdf_PyMuPDF/tests/test_textbox.py | """
Fill a given text in a rectangle on some PDF page using
1. TextWriter object
2. Basic text output
Check text is indeed contained in given rectangle.
"""
import pymupdf
text = """Der Kleine Schwertwal (Pseudorca crassidens), auch bekannt als Unechter oder Schwarzer Schwertwal, ist eine Art der Delfine (Delphinidae... | 10,628 | Python | .py | 238 | 36.264706 | 549 | 0.627479 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,342 | test_docs_samples.py | pymupdf_PyMuPDF/tests/test_docs_samples.py | '''
Test sample scripts in docs/samples/.
'''
import glob
import os
import pytest
import runpy
# We only look at sample scripts that can run standalone (i.e. don't require
# sys.argv).
#
root = os.path.abspath(f'{__file__}/../..')
samples = []
for p in glob.glob(f'{root}/docs/samples/*.py'):
if os.path.basename(p... | 1,801 | Python | .py | 55 | 24.909091 | 76 | 0.565442 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,343 | test_objectstreams.py | pymupdf_PyMuPDF/tests/test_objectstreams.py | import pymupdf
def test_objectstream1():
"""Test save option "use_objstms".
This option compresses PDF object definitions into a special object type
"ObjStm". We test its presence by searching for that /Type.
"""
if not hasattr(pymupdf, "mupdf"):
# only implemented for rebased
retu... | 2,432 | Python | .py | 68 | 29.367647 | 76 | 0.642827 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,344 | test_embeddedfiles.py | pymupdf_PyMuPDF/tests/test_embeddedfiles.py | """
Tests for PDF EmbeddedFiles functions.
"""
import pymupdf
def test_embedded1():
doc = pymupdf.open()
buffer = b"123456678790qwexcvnmhofbnmfsdg4589754uiofjkb-"
doc.embfile_add(
"file1",
buffer,
filename="testfile.txt",
ufilename="testfile-u.txt",
desc="Descriptio... | 688 | Python | .py | 22 | 26.227273 | 64 | 0.654135 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,345 | test_general.py | pymupdf_PyMuPDF/tests/test_general.py | # encoding utf-8
"""
* Confirm sample doc has no links and no annots.
* Confirm proper release of file handles via Document.close()
* Confirm properly raising exceptions in document creation
"""
import io
import os
import pymupdf
import pathlib
import pickle
import platform
import re
import subprocess
import sys
impor... | 54,825 | Python | .py | 1,337 | 33.103964 | 312 | 0.611417 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,346 | test_tables.py | pymupdf_PyMuPDF/tests/test_tables.py | import os
import io
from pprint import pprint
import pymupdf
import pickle
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "chinese-tables.pdf")
pickle_file = os.path.join(scriptdir, "resources", "chinese-tables.pickle")
def test_table1():
"""Compare pickled... | 9,918 | Python | .py | 269 | 30.260223 | 80 | 0.606682 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,347 | test_textsearch.py | pymupdf_PyMuPDF/tests/test_textsearch.py | """
"test_search1":
Search for some text on a PDF page, and compare content of returned hit
rectangle with the searched text.
"test_search2":
Text search with 'clip' parameter - clip rectangle contains two occurrences
of searched text. Confirm search locations are inside clip.
"""
import os
import pymupdf
scriptdir... | 1,552 | Python | .py | 42 | 33.047619 | 87 | 0.706 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,348 | test_word_delimiters.py | pymupdf_PyMuPDF/tests/test_word_delimiters.py | import pymupdf
import string
def test_delimiters():
"""Test changing word delimiting characters."""
doc = pymupdf.open()
page = doc.new_page()
text = "word1,word2 - word3. word4?word5."
page.insert_text((50, 50), text)
# Standard words extraction:
# only spaces and line breaks start a new... | 756 | Python | .py | 18 | 37.388889 | 82 | 0.664393 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,349 | test_toc.py | pymupdf_PyMuPDF/tests/test_toc.py | """
* Verify equality of generated TOCs and expected results.
* Verify TOC deletion works
* Verify manipulation of single TOC item works
* Verify stability against circular TOC items
"""
import os
import sys
import pymupdf
import pathlib
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(s... | 9,763 | Python | .py | 237 | 33.160338 | 169 | 0.576624 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,350 | test_tesseract.py | pymupdf_PyMuPDF/tests/test_tesseract.py | import os
import platform
import pymupdf
def test_tesseract():
'''
This checks that MuPDF has been built with tesseract support.
By default we don't supply a valid `tessdata` directory, and just assert
that attempting to use Tesseract raises the expected error (which checks
that MuPDF is built wi... | 2,595 | Python | .py | 62 | 30.951613 | 89 | 0.579992 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,351 | test_named_links.py | pymupdf_PyMuPDF/tests/test_named_links.py | import pymupdf
import os
def test_2886():
"""Confirm correct insertion of a 'named' link."""
if not hasattr(pymupdf, "mupdf"):
print(f"test_2886(): not running on classic.")
return
path = os.path.abspath(f"{__file__}/../../tests/resources/cython.pdf")
doc = pymupdf.open(path)
# n... | 3,712 | Python | .py | 88 | 36.170455 | 85 | 0.632936 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,352 | test_showpdfpage.py | pymupdf_PyMuPDF/tests/test_showpdfpage.py | """
Tests:
* Convert some image to a PDF
* Insert it rotated in some rectangle of a PDF page
* Assert PDF Form XObject has been created
* Assert that image contained in inserted PDF is inside given rectangle
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
imgfile = ... | 2,009 | Python | .py | 44 | 40.136364 | 90 | 0.655385 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,353 | test_story.py | pymupdf_PyMuPDF/tests/test_story.py | import pymupdf
import os
import textwrap
def test_story():
otf = os.path.abspath(f'{__file__}/../resources/PragmaticaC.otf')
# 2023-12-06: latest mupdf throws exception if path uses back-slashes.
otf = otf.replace('\\', '/')
CSS = f"""
@font-face {{font-family: test; src: url({otf});}}
"""... | 12,865 | Python | .py | 181 | 61.314917 | 736 | 0.659003 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,354 | test_insertimage.py | pymupdf_PyMuPDF/tests/test_insertimage.py | """
* Insert same image with different rotations in two places of a page.
* Extract bboxes and transformation matrices
* Assert image locations are inside given rectangles
"""
import json
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
imgfile = os.path.join(scriptdir, "resources", "nu... | 2,020 | Python | .py | 58 | 28.448276 | 77 | 0.635149 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,355 | test_imagebbox.py | pymupdf_PyMuPDF/tests/test_imagebbox.py | """
Ensure equality of bboxes computed via
* page.get_image_bbox()
* page.get_image_info()
* page.get_bboxlog()
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "image-file1.pdf")
image = os.path.join(scriptdir, "resources", "img-tran... | 1,291 | Python | .py | 42 | 25.571429 | 68 | 0.633655 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,356 | test_metadata.py | pymupdf_PyMuPDF/tests/test_metadata.py | """
1. Read metadata and compare with stored expected result.
2. Erase metadata and assert object has indeed been deleted.
"""
import json
import os
import sys
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "001003ED.pdf")
metafile = os.path.join(... | 1,815 | Python | .py | 34 | 48.705882 | 375 | 0.638826 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,357 | test_crypting.py | pymupdf_PyMuPDF/tests/test_crypting.py | """
Check PDF encryption:
* make a PDF with owber and user passwords
* open and decrypt as owner or user
"""
import pymupdf
def test_encryption():
text = "some secret information" # keep this data secret
perm = int(
pymupdf.PDF_PERM_ACCESSIBILITY # always use this
| pymupdf.PDF_PERM_PRINT #... | 1,288 | Python | .py | 37 | 29.648649 | 69 | 0.661329 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,358 | test_object_manipulation.py | pymupdf_PyMuPDF/tests/test_object_manipulation.py | """
Check some low-level PDF object manipulations:
1. Set page rotation and compare with string in object definition.
2. Set page rotation via string manipulation and compare with result of
proper page property.
3. Read the PDF trailer and verify it has the keys "/Root", "/ID", etc.
"""
import pymupdf
import os
scr... | 2,314 | Python | .py | 61 | 33.196721 | 78 | 0.664732 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,359 | test_badfonts.py | pymupdf_PyMuPDF/tests/test_badfonts.py | """
Ensure we can deal with non-Latin font names.
"""
import os
import pymupdf
def test_survive_names():
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "has-bad-fonts.pdf")
doc = pymupdf.open(filename)
print("File '%s' uses the following fonts o... | 396 | Python | .py | 12 | 29.416667 | 72 | 0.682415 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,360 | test_2634.py | pymupdf_PyMuPDF/tests/test_2634.py | import pymupdf
import difflib
import json
import os
import pprint
def test_2634():
if not hasattr(pymupdf, 'mupdf'):
print('test_2634(): Not running on classic.')
return
path = os.path.abspath(f'{__file__}/../../tests/resources/test_2634.pdf')
with pymupdf.open(path) as pdf, pymupdf.open(... | 2,011 | Python | .py | 56 | 24.535714 | 77 | 0.498458 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,361 | test_pagelabels.py | pymupdf_PyMuPDF/tests/test_pagelabels.py | """
Define some page labels in a PDF.
Check success in various aspects.
"""
import pymupdf
def make_doc():
"""Makes a PDF with 10 pages."""
doc = pymupdf.open()
for i in range(10):
page = doc.new_page()
return doc
def make_labels():
"""Return page label range rules.
- Rule 1: labels... | 1,742 | Python | .py | 49 | 30.693878 | 76 | 0.58076 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,362 | test_widgets.py | pymupdf_PyMuPDF/tests/test_widgets.py | # -*- coding: utf-8 -*-
"""
Test PDF field (widget) insertion.
"""
import pymupdf
import os
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "widgettest.pdf")
file_2333 = os.path.join(scriptdir, "resources", "test-2333.pdf")
doc = pymupdf.open()
page = doc.new_pa... | 10,684 | Python | .py | 294 | 29.530612 | 83 | 0.616084 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,363 | test_remove-rotation.py | pymupdf_PyMuPDF/tests/test_remove-rotation.py | import os
import pymupdf
from gentle_compare import gentle_compare
scriptdir = os.path.dirname(__file__)
def test_remove_rotation():
"""Remove rotation verifying identical appearance and text."""
filename = os.path.join(scriptdir, "resources", "test-2812.pdf")
doc = pymupdf.open(filename)
# We alway... | 1,280 | Python | .py | 26 | 42.538462 | 86 | 0.6656 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,364 | test_annots.py | pymupdf_PyMuPDF/tests/test_annots.py | # -*- coding: utf-8 -*-
"""
Test PDF annotation insertions.
"""
import os
import pymupdf
import gentle_compare
pymupdf.TOOLS.set_annot_stem("jorj")
red = (1, 0, 0)
blue = (0, 0, 1)
gold = (1, 1, 0)
green = (0, 1, 0)
scriptdir = os.path.dirname(__file__)
displ = pymupdf.Rect(0, 50, 0, 50)
r = pymupdf.Rect(72, 72, ... | 13,734 | Python | .py | 353 | 31.824363 | 110 | 0.604371 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,365 | test_balance_count.py | pymupdf_PyMuPDF/tests/test_balance_count.py | import pymupdf
def test_q_count():
"""Testing graphics state balances and wrap_contents().
Take page's contents and generate various imbalanced graphics state
situations. Each time compare q-count with expected results.
Finally confirm we are out of balance using "is_wrapped", wrap the
contents o... | 2,213 | Python | .py | 45 | 43.866667 | 81 | 0.68165 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,366 | test_insertpdf.py | pymupdf_PyMuPDF/tests/test_insertpdf.py | """
* Join multiple PDFs into a new one.
* Compare with stored earlier result:
- must have identical object definitions
- must have different trailers
* Try inserting files in a loop.
"""
import io
import os
import re
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
resources = os.path.jo... | 6,088 | Python | .py | 160 | 31.04375 | 97 | 0.607483 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,367 | test_flake8.py | pymupdf_PyMuPDF/tests/test_flake8.py | import pymupdf
import os
import subprocess
import sys
def test_flake8():
'''
Check rebased Python code with flake8.
'''
if not hasattr(pymupdf, 'mupdf'):
print(f'Not running flake8 with classic implementation.')
return
ignores = (
'E123', # closing bracket does not mat... | 2,575 | Python | .py | 51 | 40.490196 | 113 | 0.614439 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,368 | test_2548.py | pymupdf_PyMuPDF/tests/test_2548.py | import os
import pymupdf
root = os.path.abspath(f'{__file__}/../..')
def test_2548():
"""Text extraction should fail because of PDF structure cycle.
Old MuPDF version did not detect the loop.
"""
print(f'test_2548(): {pymupdf.mupdf_version_tuple=}')
if pymupdf.mupdf_version_tuple < (1, 23, 4):
... | 1,947 | Python | .py | 46 | 33.565217 | 109 | 0.600211 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,369 | test_nonpdf.py | pymupdf_PyMuPDF/tests/test_nonpdf.py | """
* Check EPUB document is no PDF
* Check page access using (chapter, page) notation
* Re-layout EPUB ensuring a previous location is memorized
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "Bezier.epub")
doc = pymupdf.open(filena... | 1,054 | Python | .py | 28 | 33.535714 | 90 | 0.676153 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,370 | test_pagedelete.py | pymupdf_PyMuPDF/tests/test_pagedelete.py | """
----------------------------------------------------
This tests correct functioning of multi-page delete
----------------------------------------------------
Create a PDF in memory with 100 pages with a unique text each.
Also create a TOC with a bookmark per page.
On every page after the first to-be-deleted page, a... | 3,156 | Python | .py | 79 | 35.278481 | 77 | 0.63761 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,371 | test_geometry.py | pymupdf_PyMuPDF/tests/test_geometry.py | """
* Check various construction methods of rects, points, matrices
* Check matrix inversions in variations
* Check algebra constructs
"""
import os
import pymupdf
def test_rect():
assert tuple(pymupdf.Rect()) == (0, 0, 0, 0)
if hasattr(pymupdf, 'mupdf'):
assert tuple(pymupdf.Rect(y0=12)) == (0, 12, ... | 10,276 | Python | .py | 321 | 26.292835 | 558 | 0.587832 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,372 | test_page_links.py | pymupdf_PyMuPDF/tests/test_page_links.py | import pymupdf
import os
def test_page_links_generator():
# open some arbitrary PDF
path = os.path.abspath(f"{__file__}/../../tests/resources/2.pdf")
doc = pymupdf.open(path)
# select an arbitrary page
page = doc[-1]
# iterate over pages.links
link_generator = page.links()
links = l... | 367 | Python | .py | 12 | 26.166667 | 69 | 0.665714 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,373 | test_mupdf_regressions.py | pymupdf_PyMuPDF/tests/test_mupdf_regressions.py | import pymupdf
import os
from gentle_compare import gentle_compare
scriptdir = os.path.abspath(os.path.dirname(__file__))
def test_707448():
"""Confirm page content cleaning does not destroy page appearance."""
filename = os.path.join(scriptdir, "resources", "test-707448.pdf")
doc = pymupdf.open(filename... | 3,402 | Python | .py | 91 | 31.912088 | 93 | 0.668894 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,374 | run_compound.py | pymupdf_PyMuPDF/tests/run_compound.py | #! /usr/bin/env python3
'''
Runs a command using different implementations of PyMuPDF:
1. Run with rebased implementation of PyMuPDF.
2. As 1 but also set PYMUPDF_USE_EXTRA=0 to disable use of C++ optimisations.
Example usage:
./PyMuPDF/tests/run_compound.py python -m pytest -s PyMuPDF
Use `-i <implementati... | 3,449 | Python | .py | 96 | 28.197917 | 112 | 0.613837 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,375 | test_extractimage.py | pymupdf_PyMuPDF/tests/test_extractimage.py | """
Extract images from a PDF file, confirm number of images found.
"""
import os
import pymupdf
scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "joined.pdf")
known_image_count = 21
def test_extract_image():
doc = pymupdf.open(filename)
image_count = 1
... | 1,765 | Python | .py | 45 | 34.133333 | 98 | 0.671176 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,376 | __main__.py | pymupdf_PyMuPDF/src_classic/__main__.py | # -----------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
# Part of "PyMuPDF", Python bindings for "MuPDF" (http://mupdf.com), a
# lightweight PDF, XPS, ... | 39,739 | Python | .py | 1,019 | 30.212954 | 88 | 0.542108 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,377 | helper-python.i | pymupdf_PyMuPDF/src_classic/helper-python.i | %pythoncode %{
# ------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
#
# Part of "PyMuPDF", a Python binding for "MuPDF" (http://mupdf.com), a
# lightweig... | 81,757 | Python | .py | 1,973 | 35.428789 | 139 | 0.692846 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,378 | helper-geo-py.i | pymupdf_PyMuPDF/src_classic/helper-geo-py.i | %pythoncode %{
# ------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
#
# Part of "PyMuPDF", a Python binding for "MuPDF" (http://mupdf.com), a
# lightwei... | 34,379 | Python | .py | 936 | 27.498932 | 115 | 0.521192 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,379 | utils.py | pymupdf_PyMuPDF/src_classic/utils.py | # ------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
#
# Part of "PyMuPDF", a Python binding for "MuPDF" (http://mupdf.com), a
# lightweight PDF, XPS, an... | 181,740 | Python | .py | 4,889 | 28.353242 | 203 | 0.538779 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,380 | __init__.py | pymupdf_PyMuPDF/src_classic/__init__.py | # ------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
#
# Part of "PyMuPDF", a Python binding for "MuPDF" (http://mupdf.com), a
# lightweight PDF, XPS, an... | 23,545 | Python | .py | 460 | 46.658696 | 104 | 0.661921 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,381 | test.py | pymupdf_PyMuPDF/scripts/test.py | #! /usr/bin/env python3
'''Developer build/test script for PyMuPDF.
Examples:
./PyMuPDF/scripts/test.py --mupdf mupdf buildtest
Build and test with pre-existing local mupdf/ checkout.
./PyMuPDF/scripts/test.py buildtest
Build and test with default internal download of mupdf.
./PyMuPDF/s... | 28,116 | Python | .py | 679 | 31.518409 | 152 | 0.581985 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,382 | sysinstall.py | pymupdf_PyMuPDF/scripts/sysinstall.py | #! /usr/bin/env python3
'''
Test for Linux system install of MuPDF and PyMuPDF.
We build and install MuPDF and PyMuPDF into a root directory, then use
scripts/test.py to run PyMuPDF's pytest tests with LD_PRELOAD_PATH and
PYTHONPATH set.
PyMuPDF itself is installed using `python -m install` with a wheel created with... | 15,829 | Python | .py | 371 | 34.956873 | 115 | 0.602133 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,383 | gh_release.py | pymupdf_PyMuPDF/scripts/gh_release.py | #! /usr/bin/env python3
'''
Build+test script for PyMuPDF using cibuildwheel. Mostly for use with github
builds.
We run cibuild manually, in order to build and test PyMuPDF wheels.
As of 2024-10-08 we also support the old two wheel flavours that make up
PyMuPDF:
PyMuPDFb
Not specific to particular versi... | 24,505 | Python | .py | 565 | 33.076106 | 139 | 0.591227 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,384 | helper-python.i | pymupdf_PyMuPDF/src_classic/helper-python.i | %pythoncode %{
# ------------------------------------------------------------------------
# Copyright 2020-2022, Harald Lieder, mailto:harald.lieder@outlook.com
# License: GNU AFFERO GPL 3.0, https://www.gnu.org/licenses/agpl-3.0.html
#
# Part of "PyMuPDF", a Python binding for "MuPDF" (http://mupdf.com), a
# lightweig... | 81,757 | Python | .pyt | 1,973 | 35.428789 | 139 | 0.692846 | pymupdf/PyMuPDF | 5,009 | 480 | 32 | AGPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,385 | settings.py | SpiderLabs_Responder/settings.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 8,817 | Python | .py | 171 | 48.245614 | 139 | 0.691682 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,386 | Responder.py | SpiderLabs_Responder/Responder.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 11,158 | Python | .py | 215 | 48.874419 | 240 | 0.731607 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,387 | odict.py | SpiderLabs_Responder/odict.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 3,516 | Python | .py | 101 | 27.207921 | 79 | 0.580171 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,388 | utils.py | SpiderLabs_Responder/utils.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 12,730 | Python | .py | 283 | 42.300353 | 236 | 0.659291 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,389 | packets.py | SpiderLabs_Responder/packets.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 75,480 | Python | .py | 1,222 | 58.794599 | 1,786 | 0.657777 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,390 | fingerprint.py | SpiderLabs_Responder/fingerprint.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 2,088 | Python | .py | 53 | 36.811321 | 110 | 0.725383 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,391 | Icmp-Redirect.py | SpiderLabs_Responder/tools/Icmp-Redirect.py | #! /usr/bin/env python
# NBT-NS/LLMNR Responder
# Created by Laurent Gaffie
# Copyright (C) 2014 Trustwave Holdings, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of th... | 10,516 | Python | .py | 217 | 43.152074 | 413 | 0.64244 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,392 | FindSMB2UPTime.py | SpiderLabs_Responder/tools/FindSMB2UPTime.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 2,160 | Python | .py | 58 | 33.103448 | 83 | 0.681166 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,393 | RelayPackets.py | SpiderLabs_Responder/tools/RelayPackets.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 15,323 | Python | .py | 308 | 42 | 649 | 0.558627 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,394 | SMBRelay.py | SpiderLabs_Responder/tools/SMBRelay.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 21,375 | Python | .py | 398 | 39.085427 | 228 | 0.544743 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,395 | BrowserListener.py | SpiderLabs_Responder/tools/BrowserListener.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 4,217 | Python | .py | 99 | 40.111111 | 106 | 0.607317 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,396 | FindSQLSrv.py | SpiderLabs_Responder/tools/FindSQLSrv.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 1,299 | Python | .py | 35 | 33.742857 | 80 | 0.644956 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,397 | DHCP.py | SpiderLabs_Responder/tools/DHCP.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 13,751 | Python | .py | 291 | 44.649485 | 213 | 0.571875 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,398 | POP3.py | SpiderLabs_Responder/servers/POP3.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 1,493 | Python | .py | 44 | 31 | 71 | 0.7213 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |
21,399 | Browser.py | SpiderLabs_Responder/servers/Browser.py | #!/usr/bin/env python
# This file is part of Responder
# Original work by Laurent Gaffie - Trustwave Holdings
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, o... | 6,313 | Python | .py | 157 | 36.961783 | 188 | 0.695289 | SpiderLabs/Responder | 4,450 | 1,663 | 44 | GPL-3.0 | 9/5/2024, 5:12:54 PM (Europe/Amsterdam) |