Forum Archive

PDF to Image Conversion

cvp

I download a pdf file via Safari and I "open it" with a Pythonista script, thus the script runs in Appex mode.
The script splits the PDF into its pages (using pyPDF2).
I want to display each PDF page (one at a time, asking the user if he wants to keep this page or not) as the background of the share extension view.
I already have done that with a photo but, here, I need to convert the PDF page file into either an image, either a JPG/PNG file...
Somebody can help me?

Webmaster4o

You may not be able to do this in Pythonista, Objective C may have some kind of method though.

Check out this stackoverflow question for some info on a Python approach. You might have some luck converting this objective-c code into Pythonista code.

cvp

Thanks for your so quick answer.
I had searched through the forum, but I guess I gave bad search arguments...sorry

cvp

Even the console.quicklook does not display something with a pdf file.
If I click on a PDF in Pythonista, the little menu (open in or Quick Look), if I click "Quick Look" displays the PDF correctly.
Strange

Webmaster4o

Huh. You wouldn't be able to display a UI on top of that anyway I don't think.

cvp

In other scripts, in apex mode, I start a ui.view as background of the share sheet.
And in the ui.view, I display a ui.ImageView with the background bounds, filled with a photo,
or an ui.WebView.
Thus I hoped to transform the pdf into a jpg and display the jpg in the ui.ImageView as background of my Share Sheet window.
I'm not sure I'm clear enough in my poor English...

omz

Web views can render PDFs, so maybe you can split the original PDF into multiple (1-page) PDF files (using PyPDF2), and then show them (one after another) using a web view?

omz

...it would also be possible to render a PDF into a JPEG/PNG image using objc_util of course, but I think the approach I outlined above would be easier, and it doesn't seem like you'd need the image for anything other than displaying it in the UI.

cvp

Thanks, I'll try with the WebView, because using objc_util seems to complex for me..
But how can I load a pdf local file in WebView, I only know load_url and load_html, sorry

omz

@cvp You can load local files in a web view using a file:// URL. Here's a snippet for converting from a file path to a file URL (from this StackOverflow answer):

import urlparse, urllib

def path2url(path):
    return urlparse.urljoin(
      'file:', urllib.pathname2url(path))
cvp

Thanks
I'am sorry because I should be able to find that my-self...
I really love your app for all I can do with it.

JonesMartin

Softaken PDF to images Converter is a more efficient pdf to images conversion application, which is able to migrate pdf to jpg format with original output quality and fast conversion speed. Moreover, PDF to image Converter is also can easy-to-use software, just simple several clicks can guide users to the friendly interface and finish pdf to image conversion quickly.

MichaelJames

Try Softaken PDF Champ

madivad

I do hate reading a post and then finding out the question was asked 5 years ago... It would be nice if somehow the most recent question is what pops up when I visit something like this... (don't worry, I'm sending this to nodebb as well!)

eaglesha

This information useful for me. I can use it and do file sharing for free to share it with everyone! Thank you for this information.