omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    PDF to Image Conversion

    Pythonista
    7
    15
    8285
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by

      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?

      1 Reply Last reply Reply Quote 1
      • Webmaster4o
        Webmaster4o last edited by 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.

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp last edited by

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

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp last edited by

            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

            1 Reply Last reply Reply Quote 0
            • Webmaster4o
              Webmaster4o last edited by

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

              1 Reply Last reply Reply Quote 0
              • cvp
                cvp last edited by

                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...

                1 Reply Last reply Reply Quote 0
                • omz
                  omz last edited by

                  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?

                  1 Reply Last reply Reply Quote 0
                  • omz
                    omz last edited by

                    ...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.

                    1 Reply Last reply Reply Quote 1
                    • cvp
                      cvp last edited by

                      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

                      1 Reply Last reply Reply Quote 0
                      • omz
                        omz last edited by

                        @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))
                        
                        1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp last edited by

                          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.

                          1 Reply Last reply Reply Quote 1
                          • JonesMartin
                            JonesMartin last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • MichaelJames
                              MichaelJames last edited by

                              This post is deleted!
                              1 Reply Last reply Reply Quote 0
                              • madivad
                                madivad last edited by

                                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!)

                                1 Reply Last reply Reply Quote 0
                                • eaglesha
                                  eaglesha last edited by 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.

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Powered by NodeBB Forums | Contributors