diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index c8ade0ae..04eaf990 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -592,9 +592,15 @@ def select_image_layer( re_symlink(page_pdf, output_file) else: pageinfo = get_pageinfo(image, pdfinfo, pdfinfo_lock) - dpi = round(max(pageinfo['xres'], pageinfo['yres'], options.oversample)) + dpi = round(max(pageinfo['xres'], pageinfo['yres'], + options.oversample)) + imgsize = '{0}dpix{1}dpi'.format(dpi, dpi) + layout_fun = img2pdf.get_layout_fun(None, imgsize, None, None, None) + with open(output_file, 'wb') as pdf: - img2pdf.convert([image], dpi=dpi, outputstream=pdf) + pdf.write(img2pdf.convert( + [image], producer="img2pdf", with_pdfrw=False, + layout_fun=layout_fun)) @active_if(options.pdf_renderer == 'hocr') diff --git a/requirements.txt b/requirements.txt index 7ba54a41..18cb6b81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,4 @@ ruffus==2.6.3 Pillow==3.1.1 reportlab==3.2.0 PyPDF2==1.25.1 -git+https://github.com/jbarlow83/img2pdf.git@0.1.5.dev - +img2pdf==0.2 diff --git a/setup.py b/setup.py index 1bd8b17e..243b94cd 100644 --- a/setup.py +++ b/setup.py @@ -214,7 +214,7 @@ setup( 'Pillow>=2.4.0', 'reportlab>=3.1.44', 'PyPDF2>=1.25.1', - 'img2pdf==0.1.5.dev' + 'img2pdf>=0.2.0' ], tests_require=tests_require, entry_points={