Question Gilberto Alves · Sep 11, 2023

How would one convert a PDF to an image using Ensemble/IRIS

Suppose I have a PDF and I need to convert it to an IMAGE (it can be a JPG or PNG)

Does anyone have an idea?

Product version: IRIS 2021.1

Comments

Ben Spead · Sep 11, 2023

This sounds like a classic example of leveraging embedded Python in IRIS to make use of the very large volume of python libraries that do just about anything :)  Here is an article that I found on a quick Google search on how to do this in Python:

https://www.geeksforgeeks.org/convert-pdf-to-image-using-python/

You could just leverage the Python capabilities of InterSystems IRIS to make use of how this problem has been solved in Python! 

0
Gilberto Alves  Sep 11, 2023 to Ben Spead

Hi Ben Spead! thank you very much for the tip!
Unfortunately my environment is not ready to use the embedded Python.
I'm thinking about doing file conversions, but I'm in a hurry to resolve this issue and I don't know where else to go.

0
Ben Spead  Sep 12, 2023 to Gilberto Alves

In that case, install Python on your machine with the library you want to use, and call $zf(-100) to execute your python script.  Later when you upgrade your environment you can move to using embedded Python directly.  

0
Luis Angel Pérez Ramos · Sep 12, 2023

Well, if your IRIS doesn't support Embedded Python you can do the following (if you are using a Linux Server):

  1. Install some application like ImageMagick in your server
  2. From your Business Operation use $ZF(-100) function to execute in the server the magick command to convert the PDG to JPG, something like:
    $ZF(-100,"","magick","\usr\image.pdf","\usr\image.jpg") 
  3. Maybe it takes some time to finish, you can wait to the end of the execution or just create a business service to get all the new pdf files.
0
Gilberto Alves  Sep 12, 2023 to Luis Angel Pérez Ramos

I think this is the quickest alternative solution. Thank you very much Luis Angel!

0