forked from 0x2620/pandora
use pdftocairo for pdf preview
This commit is contained in:
parent
6c5fc9030a
commit
e1f7c784ad
1 changed files with 12 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -22,11 +23,17 @@ def pdfinfo(pdf):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def extract_pdfpage(pdf, image, page):
|
def extract_pdfpage(pdf, image, page):
|
||||||
page -= 1
|
page = str(page)
|
||||||
cmd = ['convert', '%s[%d]' % (pdf, page),
|
cmd = [
|
||||||
'-background', 'white', '-flatten', '-resize', '1024x1024', image]
|
'pdftocairo',
|
||||||
p = subprocess.Popen(cmd, close_fds=True)
|
'-jpeg',
|
||||||
p.wait()
|
'-f', page, '-l', page,
|
||||||
|
'-singlefile',
|
||||||
|
'-scale-to', '2048',
|
||||||
|
pdf,
|
||||||
|
os.path.splitext(image)[0]
|
||||||
|
]
|
||||||
|
subprocess.call(cmd, stdout=open('/dev/null', 'wb'))
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def get_documents(text):
|
def get_documents(text):
|
||||||
|
|
Loading…
Reference in a new issue