I want to convert the first page of pdf file as an image object. So thought of using subprocess. Subprocess only takes string as a parameter. Is there any way that I can pass a pdf page object and get image as an output.
Example:
instead of
import subprocess
params = ['convert','in.pdf','thumb.jpg']
subprocess.check_call(params)
I want something like this
import subprocess
from PyPDF2 import PdfFileWriter, PdfFileReader
q = PdfFileReader(open("in.pdf","rb"),strict=False)
page = q.getPage(0)
params = ['convert',page,'thumb.jpg']
thumbnail = subprocess.check_call(params)
I tried but failed to get the output. Is there any way to accomplish this?