mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Try to detect image based PDFs and give a more intelligent error message for them
This commit is contained in:
parent
8793c335ac
commit
82a5116f38
@ -41,7 +41,10 @@ def generate_html(pathtopdf, logger):
|
|||||||
err = p.stderr.read()
|
err = p.stderr.read()
|
||||||
raise ConversionError, err
|
raise ConversionError, err
|
||||||
if not os.path.exists(index) or os.stat(index).st_size < 100:
|
if not os.path.exists(index) or os.stat(index).st_size < 100:
|
||||||
raise ConversionError(os.path.basename(pathtopdf) + ' does not allow copying of text.')
|
raise ConversionError(os.path.basename(pathtopdf) + _(' does not allow copying of text.'))
|
||||||
|
raw = open(index).read(4000)
|
||||||
|
if not '<br' in raw:
|
||||||
|
raise ConversionError(os.path.basename(pathtopdf) + _(' is an image based PDF. Only conversion of text based PDFs is supported.'))
|
||||||
finally:
|
finally:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
return index
|
return index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user