How to convert a renderID of a PDF to a JPEG or PNG?

I have generated a PDF from a third-party API which returns me with a renderID as shown here:

I am trying to pass this PDF into the Stripe API for updating a product in the 'images' field:

Stripe API Reference - Update a product

The problem I am running into is that the Stripe API only accepts JPEGS/PNGS so I somehow need to convert my PDF to one of these formats to pass it into the API.

Hello! I’m not sure if we have this capability built-in to Retool, but perhaps there’s a JS library we can import and use.

See the “Custom JavaScript Libraries + NPM modules” section here:

https://docs.retool.com/docs/custom-js-code

This guide seems to indicate that PDF -> JPG might be possible using the PDF.JS library, but I haven’t been able to get PDF.JS to work in Retool.

There are also seem to be a few APIs that can do this conversation, but again, I haven’t been able to get them to work in Retool.

Do you know if Base64 is accepted by the endpoint you’d like to use?

Hi, thank you for the response.

Unfortunately, Base64 is not accepted in this API. The accepted format is a "URL in the form of either a JPEG or PNG.

I'll look into the libraries and attempt to find a compromise.

That seems like your best bet! I double checked with my team today and pdf to jpeg don’t seem to be supported in Retool natively :pensive:

Let me know if I can help with anything else though, hopefully with a better resolution!

When did PDF to jpeg supported in Retool natively?

Hey @afaq_mehmood! Are you asking about timelines for rendering a PDF to/from JPEG in Retool?

Yes

Got it, thank you. It’s not on our current roadmap, but we’ll keep you updated in this thread! :+1:

1 Like