Render PDF in image component

I want to display images of invoices, some of which are saved as .png files and some as .pdf files.
When I use an image component it doesn't render the pdf files.
Any solutions?

It should be something like this. first convert your pdf and image to base64.

Another idea is to place them both on the same place on the canvas & then show/hide them dynamically so that only the pdf component or image component is showing as needed