From 075f59b8d11143e54fe4f646284a83337e97ff69 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Apr 2009 20:57:37 -0700 Subject: [PATCH] PDF Input: calibre now supports conversion of PDF version > 1.5 as well --- installer/osx/freeze.py | 4 +++- installer/windows/freeze.py | 4 +++- src/calibre/debug.py | 8 ++++---- src/calibre/ebooks/lrf/pdf/convert_from.py | 11 ++++++----- src/calibre/gui2/main.py | 4 ++-- src/calibre/linux.py | 4 ++-- src/calibre/trac/plugins/download.py | 1 + 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/installer/osx/freeze.py b/installer/osx/freeze.py index c1e458caf8..1861596f61 100644 --- a/installer/osx/freeze.py +++ b/installer/osx/freeze.py @@ -246,7 +246,9 @@ _check_symlinks_prescript() print print 'Adding pdftohtml' - os.link(os.path.expanduser('~/pdftohtml'), os.path.join(frameworks_dir, 'pdftohtml')) + os.link(os.path.expanduser('~/pdftohtml/pdftohtml'), os.path.join(frameworks_dir, 'pdftohtml')) + os.link(os.path.expanduser('~/pdftohtml/libpoppler.4.dylib'), + os.path.join(frameworks_dir, 'libpoppler.4.dylib')) print 'Adding plugins' module_dir = os.path.join(resource_dir, 'lib', 'python2.6', 'lib-dynload') print 'Adding fontconfig' diff --git a/installer/windows/freeze.py b/installer/windows/freeze.py index 0829907d01..99cbb0be38 100644 --- a/installer/windows/freeze.py +++ b/installer/windows/freeze.py @@ -9,7 +9,7 @@ Freeze app into executable using py2exe. QT_DIR = 'C:\\Qt\\4.4.3' LIBUSB_DIR = 'C:\\libusb' LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll' -PDFTOHTML = 'C:\\pdftohtml\\pdftohtml.exe' +PDFTOHTML = 'C:\\cygwin\\home\\kovid\\poppler-0.10.6\\rel\\pdftohtml.exe' IMAGEMAGICK_DIR = 'C:\\ImageMagick' FONTCONFIG_DIR = 'C:\\fontconfig' VC90 = r'C:\VC90.CRT' @@ -98,6 +98,8 @@ class BuildEXE(py2exe.build_exe.py2exe): shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR))) print '\tAdding pdftohtml' shutil.copyfile(PDFTOHTML, os.path.join(PY2EXE_DIR, os.path.basename(PDFTOHTML))) + shutil.copyfile(PDFTOHTML+'.manifest', os.path.join(PY2EXE_DIR, + os.path.basename(PDFTOHTML)+'.manifest')) print '\tAdding ImageMagick' for f in os.listdir(IMAGEMAGICK_DIR): shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f)) diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 6444eaa691..9dee6b2a86 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -17,10 +17,10 @@ def option_parser(): Run an embedded python interpreter. ''') - parser.add_option('--update-module', + parser.add_option('-u', '--update-module', default=False, + action='store_true', help='Update the specified module in the frozen library. '+ - 'Module specifications are of the form full.name.of.module,path_to_module.py', - default=None + 'Module specifications are of the form full.name.of.module path_to_module.py', ) parser.add_option('-c', '--command', help='Run python code.', default=None) parser.add_option('-e', '--exec-file', default=None, help='Run the python code in file.') @@ -143,7 +143,7 @@ def main(args=sys.argv): from calibre.gui2.main import main main(['calibre']) elif opts.update_module: - mod, path = opts.update_module.partition(',')[0], opts.update_module.partition(',')[-1] + mod, path = args[1:3] update_module(mod, os.path.expanduser(path)) elif opts.command: sys.argv = args[:1] diff --git a/src/calibre/ebooks/lrf/pdf/convert_from.py b/src/calibre/ebooks/lrf/pdf/convert_from.py index cc8ebd64b8..cbb4424378 100644 --- a/src/calibre/ebooks/lrf/pdf/convert_from.py +++ b/src/calibre/ebooks/lrf/pdf/convert_from.py @@ -36,9 +36,10 @@ def generate_html(pathtopdf, tdir): index = os.path.join(tdir, 'index.html') # This is neccessary as pdftohtml doesn't always (linux) respect absolute paths pathtopdf = os.path.abspath(pathtopdf) - cmd = (PDFTOHTML, '-enc', 'UTF-8', '-noframes', '-p', '-nomerge', pathtopdf, os.path.basename(index)) + cmd = (PDFTOHTML, '-enc', 'UTF-8', '-noframes', '-p', '-nomerge', + '-nodrm', pathtopdf, os.path.basename(index)) cwd = os.getcwd() - + try: os.chdir(tdir) try: @@ -67,7 +68,7 @@ def generate_html(pathtopdf, tdir): raise ConversionError, err if not os.path.exists(index) or os.stat(index).st_size < 100: raise DRMError() - + raw = open(index, 'rb').read() open(index, 'wb').write('\n'+raw) if not '