Compare commits

...
9 Commits
8 changed files with 42 additions and 20 deletions
+4
View File
@@ -27,6 +27,10 @@ matrix:
language: python language: python
python: 3.6 python: 3.6
env: EXTRAS=[fitz] env: EXTRAS=[fitz]
- os: osx
osx_image: xcode8
language: generic
env: EXTRAS=
- os: osx - os: osx
osx_image: xcode8 osx_image: xcode8
language: generic language: generic
+14
View File
@@ -5,6 +5,20 @@ OCRmyPDF uses `semantic versioning <http://semver.org/>`_ for its command line i
The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API.
v6.1.2
------
- Upgrade to PyMuPDF v1.12.5 which includes a more complete fix to #239.
- Add ``defusedxml`` dependency.
v6.1.1
------
- Fix text being reported as found on all pages if PyMuPDF is not installed.
v6.1.0 v6.1.0
------ ------
+3
View File
@@ -12,3 +12,6 @@ ignore =
norecursedirs = lib .pc .git output cache resources norecursedirs = lib .pc .git output cache resources
testpaths = tests testpaths = tests
addopts = -n auto addopts = -n auto
[metadata]
license_file = LICENSE
+11 -10
View File
@@ -232,26 +232,27 @@ setup(
"Topic :: Text Processing :: Indexing", "Topic :: Text Processing :: Indexing",
"Topic :: Text Processing :: Linguistic", "Topic :: Text Processing :: Linguistic",
], ],
python_requires='>=3.5', python_requires=' >= 3.5',
setup_requires=[ setup_requires=[
'cffi >= 1.9.1', # to build the leptonica module
'pytest-runner', # to enable python setup.py test
'setuptools_scm', # so that version will work 'setuptools_scm', # so that version will work
'cffi>=1.9.1', # to build the leptonica module
'pytest-runner' # to enable python setup.py test
], ],
use_scm_version={'version_scheme': 'post-release'}, use_scm_version={'version_scheme': 'post-release'},
cffi_modules=[ cffi_modules=[
'src/ocrmypdf/lib/compile_leptonica.py:ffibuilder' 'src/ocrmypdf/lib/compile_leptonica.py:ffibuilder'
], ],
install_requires=[ install_requires=[
'ruffus==2.6.3', # pinned - ocrmypdf implements a 2.6.3 workaround 'cffi >= 1.9.1', # must be a setup and install requirement
'Pillow>=4.0.0', # Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3 'defusedxml >= 0.5.0', # pure Python, so track HEAD closely
'reportlab>=3.3.0', # oldest released version with sane image handling 'img2pdf >= 0.2.4', # pure Python, so track HEAD closely
'PyPDF2>=1.26', # pure Python, so track HEAD closely 'Pillow >= 4.0.0', # Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3
'img2pdf>=0.2.3', # pure Python, so track HEAD closely 'PyPDF2 >= 1.26', # pure Python, so track HEAD closely
'cffi>=1.9.1', # must be a setup and install requirement 'reportlab >= 3.3.0', # oldest released version with sane image handling
'ruffus == 2.6.3', # pinned - ocrmypdf implements a 2.6.3 workaround
], ],
extras_require={ extras_require={
'fitz': ['PyMuPDF == 1.12.4'] # pinned to avoid problems with 1.12.4.x 'fitz': ['PyMuPDF >= 1.12.5'] # for table of contents bug
}, },
tests_require=tests_require, tests_require=tests_require,
entry_points={ entry_points={
+5
View File
@@ -17,7 +17,12 @@
"""Bindings to external libraries""" """Bindings to external libraries"""
import os as _os
try: try:
import fitz import fitz
except ImportError: except ImportError:
fitz = None fitz = None
if _os.environ.get('_OCRMYPDF_NO_FITZ'):
fitz = None
+2 -2
View File
@@ -18,7 +18,7 @@
# Generate a PDFA_def.ps file for Ghostscript >= 9.14 # Generate a PDFA_def.ps file for Ghostscript >= 9.14
from string import Template from string import Template
import codecs from binascii import hexlify
import pkg_resources import pkg_resources
import PyPDF2 as pypdf import PyPDF2 as pypdf
@@ -93,7 +93,7 @@ def encode_text_string(s: str) -> str:
return '' return ''
utf16_bytes = s.encode('utf-16be') utf16_bytes = s.encode('utf-16be')
ascii_hex_bytes = codecs.encode(b'\xfe\xff' + utf16_bytes, 'hex') ascii_hex_bytes = hexlify(b'\xfe\xff' + utf16_bytes)
ascii_hex_str = ascii_hex_bytes.decode('ascii').lower() ascii_hex_str = ascii_hex_bytes.decode('ascii').lower()
return ascii_hex_str return ascii_hex_str
+1 -1
View File
@@ -205,7 +205,7 @@ def _interpret_contents(contentstream, initial_shorthand=UNIT_SQUARE):
return ContentsInfo( return ContentsInfo(
xobject_settings=xobject_settings, xobject_settings=xobject_settings,
inline_images=inline_images, inline_images=inline_images,
found_text=True) found_text=found_text)
def _get_dpi(ctm_shorthand, image_size): def _get_dpi(ctm_shorthand, image_size):
+1 -6
View File
@@ -1039,12 +1039,7 @@ def merge_pages_mupdf(
metadata = fitz.open(metadata_file) metadata = fitz.open(metadata_file)
toc = metadata.getToC(simple=False) toc = metadata.getToC(simple=False)
def filter_toc_pages(): doc.setToC(toc)
"fitz does not escape parens properly"
for entry in toc:
entry[1] = entry[1].replace('(', '').replace(')', '')
yield entry
doc.setToC([item for item in filter_toc_pages()])
doc.setMetadata(pymupdf_metadata) doc.setMetadata(pymupdf_metadata)
doc.save(output_file, garbage=4, deflate=True) doc.save(output_file, garbage=4, deflate=True)