diff --git a/ocrmypdf/pdfa.py b/ocrmypdf/pdfa.py index 1b7249e6..6375b958 100644 --- a/ocrmypdf/pdfa.py +++ b/ocrmypdf/pdfa.py @@ -67,8 +67,9 @@ def encode_text_string(s: str) -> str: From PDF 32000-1:2008 a string object may be included in hexademical form if it is enclosed in angle brackets. For general Unicode the string should be UTF-16 (big endian) with byte order marks. A non-hexademical - presentation is possible but this is preferable since it allows the output - Postscript file to be completely ASCII. + representation is doable but this is preferable since it allows the output + Postscript file to be completely ASCII and no escaping of Postscript + characters is necessary. ''' if s == '': return '' diff --git a/ocrmypdf/test/test_pageinfo.py b/ocrmypdf/test/test_pageinfo.py index 8fc87980..9b733e5c 100644 --- a/ocrmypdf/test/test_pageinfo.py +++ b/ocrmypdf/test/test_pageinfo.py @@ -9,7 +9,9 @@ import os import sys import shutil from nose.tools import * +from pkg_resources import Requirement, resource_filename +req = Requirement.parse('ocrmypdf') TEST_OUTPUT = os.path.join(os.path.dirname(__file__), 'output') @@ -93,3 +95,12 @@ def test_single_page_inline_image(): pageinfo.pdf_get_all_pageinfo(filename) + +def test_jpeg(): + filename = resource_filename(req, 'tests/resources/c02-22.pdf') + + pdfinfo = pageinfo.pdf_get_all_pageinfo(filename) + + pdfimage = pdfinfo[0]['images'][0] + assert pdfimage['enc'] == 'jpeg' + diff --git a/tests/resources/LinnSequencer.jpg b/tests/resources/LinnSequencer.jpg new file mode 100644 index 00000000..bb76d0c9 Binary files /dev/null and b/tests/resources/LinnSequencer.jpg differ diff --git a/tests/resources/NOTE.rst b/tests/resources/NOTE.rst index f197ee6e..7e2b7fa5 100644 --- a/tests/resources/NOTE.rst +++ b/tests/resources/NOTE.rst @@ -4,10 +4,14 @@ copyright reasons. Test files do not necessarily produce perfect (or even good) OCR results. -+--------------+--------------------------------------------------------------------------------+ -| File | Source | -+==============+================================================================================+ -| graph.pdf | Wikimedia | -+--------------+--------------------------------------------------------------------------------+ -| c02-22.pdf | Project Gutenberg: https://www.gutenberg.org/files/76/76-h/images/c02-22.jpg | -+--------------+--------------------------------------------------------------------------------+ ++-------------------+--------------------------------------------------------------------------------+ +| File | Source | ++===================+================================================================================+ +| graph.pdf | Wikimedia | ++-------------------+--------------------------------------------------------------------------------+ +| c02-22.pdf | Project Gutenberg: https://www.gutenberg.org/files/76/76-h/images/c02-22.jpg | ++-------------------+--------------------------------------------------------------------------------+ +| LinnSequencer.jpg | Wikimedia: https://upload.wikimedia.org/wikipedia/en/b/b7/LinnSequencer_hardware_MIDI_sequencer_brochure_page_2_300dpi.jpg | ++-------------------+--------------------------------------------------------------------------------+ +| congress.jpg | http://www.baxleystamps.com/litho/meiji/courts_1871.jpg | ++-------------------+--------------------------------------------------------------------------------+ diff --git a/tests/resources/congress.jpg b/tests/resources/congress.jpg new file mode 100644 index 00000000..d63d7026 Binary files /dev/null and b/tests/resources/congress.jpg differ