From 0ce2126cdc5b78440059018355494e2bdb3fd95f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 24 Sep 2010 20:31:56 -0600 Subject: [PATCH] Fix #6939 (PDF conversion fails with "spine empty") --- src/calibre/ebooks/conversion/preprocess.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 3b1239814a..92c2fe5954 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -389,6 +389,7 @@ class HTMLPreProcessor(object): if is_pdftohtml: end_rules.append((re.compile(r'

\s*(?P(<[ibu]>){0,2}\s*([A-Z \'"!]{3,})\s*([\dA-Z:]+\s){0,4}\s*(){0,2})\s*

\s*(?P(<[ibu]>){0,2}(\s*\w+){1,4}\s*(</[ibu]>){0,2}\s*<p>)?'), chap_head),) + length = -1 if getattr(self.extra_opts, 'unwrap_factor', 0.0) > 0.01: length = line_length('pdf', html, getattr(self.extra_opts, 'unwrap_factor')) if length: @@ -425,7 +426,7 @@ class HTMLPreProcessor(object): for rule in rules + end_rules: html = rule[0].sub(rule[1], html) - if is_pdftohtml: + if is_pdftohtml and length > -1: # Dehyphenate dehyphenator = Dehyphenator() html = dehyphenator(html,'pdf', length)