Example of Upload and Display of PDF Files

Hello,

anyone by accident has an example implementation of

  • Uploading multiple (PDF) files (ideally drag 'n drop)
  • view them individually

I guess the way to go would be BrowserFrame and pdf.js - but I am open to other suggestions.

1 Like

Hello,

Which version of Jmix are you using, Jmix 1.x or Jmix 2.x?

Regads,
Nikita

Hello Nikita, I am using Jmix 1.5.3.

i have an object “attachment”, where I can get the path of the uploaded Pdf-File from:
getPath() returns something like “2023/09/28/45f17a4a-3779-9061-2052-c05129da9694.pdf

i’d like to pass this value to a BrowserFrame to display the document. I assume I have to use the “relativePath” for the browser Frame.
but:
programmaticBrowserFrame.setSource(RelativePathResource.class).setPath(attachment.getFile().getPath());

only results in a 404 error - I assume I have to add/remove something to the path?

Best regards

Issue solved. had to use FileStorageResource. Should have been obvious :wink:

programmaticBrowserFrame.setSource(FileStorageResource.class)
                                        .setFileReference(attachment.getFile());

Hi Uwe

programmaticBrowserFrame

Which component do you use ?

I was thinking of <htmlObject> instead of an iFrame.

→ FlowUI 2.2.1; is <htmlObject> dataware ?

Best regards

Felix

Best solution for static pdf’s

<htmlObject data="https://web-preview.pspdfkit.com/showcases/8.pdf"/>

Regards

Felix

See also these examples for Jmix 2: