mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Input: calibre now supports conversion of PDF version > 1.5 as well
This commit is contained in:
parent
f626ae0270
commit
075f59b8d1
@ -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'
|
||||
|
@ -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))
|
||||
|
@ -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]
|
||||
|
@ -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('<!-- created by calibre\'s pdftohtml -->\n'+raw)
|
||||
if not '<br' in raw[:4000]:
|
||||
@ -105,7 +106,7 @@ def process_file(path, options, logger=None):
|
||||
tdir = PersistentTemporaryDirectory('_pdf2lrf')
|
||||
htmlfile = generate_html(pdf, tdir)
|
||||
if not options.output:
|
||||
ext = '.lrs' if options.lrs else '.lrf'
|
||||
ext = '.lrs' if options.lrs else '.lrf'
|
||||
options.output = os.path.abspath(os.path.basename(os.path.splitext(path)[0]) + ext)
|
||||
else:
|
||||
options.output = os.path.abspath(options.output)
|
||||
@ -118,7 +119,7 @@ def process_file(path, options, logger=None):
|
||||
def main(args=sys.argv, logger=None):
|
||||
parser = option_parser()
|
||||
options, args = parser.parse_args(args)
|
||||
if len(args) != 2:
|
||||
if len(args) != 2:
|
||||
parser.print_help()
|
||||
print
|
||||
print 'No pdf file specified'
|
||||
|
@ -96,12 +96,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.viewers = collections.deque()
|
||||
self.content_server = None
|
||||
self.system_tray_icon = QSystemTrayIcon(QIcon(':/library'), self)
|
||||
self.system_tray_icon.setObjectName('calibre')
|
||||
self.system_tray_icon.setToolTip('calibre')
|
||||
if not config['systray_icon']:
|
||||
self.system_tray_icon.hide()
|
||||
else:
|
||||
self.system_tray_icon.show()
|
||||
self.system_tray_menu = QMenu()
|
||||
self.system_tray_menu = QMenu(self)
|
||||
self.restore_action = self.system_tray_menu.addAction(
|
||||
QIcon(':/images/page.svg'), _('&Restore'))
|
||||
self.donate_action = self.system_tray_menu.addAction(
|
||||
|
@ -93,7 +93,7 @@ def options(option_parser):
|
||||
def opts_and_words(name, op, words):
|
||||
opts = '|'.join(options(op))
|
||||
words = '|'.join([w.replace("'", "\\'") for w in words])
|
||||
return '_'+name+'()'+\
|
||||
return ('_'+name+'()'+\
|
||||
'''
|
||||
{
|
||||
local cur opts
|
||||
@ -117,7 +117,7 @@ def opts_and_words(name, op, words):
|
||||
esac
|
||||
|
||||
}
|
||||
complete -F _'''%(opts, words) + name + ' ' + name +"\n\n"
|
||||
complete -F _'''%(opts, words) + name + ' ' + name +"\n\n").encode('utf-8')
|
||||
|
||||
|
||||
def opts_and_exts(name, op, exts):
|
||||
|
@ -19,6 +19,7 @@ DEPENDENCIES = [
|
||||
('python-dateutil', '1.4.1', 'python-dateutil', 'python-dateutil', 'python-dateutil'),
|
||||
('BeautifulSoup', '3.0.5', 'beautifulsoup', 'python-beautifulsoup', 'python-BeautifulSoup'),
|
||||
('dnspython', '1.6.0', 'dnspython', 'dnspython', 'dnspython', 'dnspython'),
|
||||
('poppler', '0.10.5', 'poppler', 'poppler', 'poppler', 'poppler'),
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user