1224
Views
6
Comments
Solved
Generating an URL access for a PDF stored in an entity
Question

Hello everyone,

I'm having a problem integrating the pdfJS Viewer plugin, since it requires an URL for the file to display and my file is stored in a Entity with attributes Name(Text), Content(Binary).

Is there a way to generate the acess URL to pass to the pdfJS Viewer?

Best Regards,

Filipe

2020-02-28 09-46-54
Eduardo Jauch
Solution

Hi Filipe,

Just create a page, and in the preparation, finish it with a Download node, passing as the content your PDF binary. You can use input parameters to define which file to download.

Than you can use this URL with the component.

Cheers.

UserImage.jpg
Jeremy Teemull

Could you clarify exactly what you mean

"Than you can use this URL with the component."

Also why is a Download node required at the end?

1) I use HtmlToPdfConverter to get a binary (this required a URL).

2) How do I get this binary into URL field for the pdfJSViewer?

UserImage.jpg
Toga Setiawan

I have same question. I create the file pdf uploader and the file stored in database as binary data.  Then, i want to preview the pdf file that stored in the database with pdfJSViewer. It needs URL, and I don't know what should I fill?

2020-02-28 09-46-54
Eduardo Jauch

The component can't show a PDF directly.
You need to have to give a URL where the PDF will be, so that the component will download the PDF.

So, create a page, in the preparation, get the PDF (from database or the convert) and provide the content to the Download Node at the end of the preparation.

Give the URL of this page to the component. 

When you show the page with the component, it will download the PDF.

Cheers.

UserImage.jpg
Muhamad Jordi

Hi Eduardo,

How to do that on a reactive web application? Thank's.

2020-03-12 15-06-24
Steven Decock

Hi Muhamad,

In a Reactive web application, what you can do is create a REST API with a GET method to retrieve the document.  That method would for example get the DocumentId as input, and Binary data as output.  

In that REST method you then use GetRequest_Submit from the HTTPRequestHandler extension to get your content from your external URL.

Then use AddHeader from HTTPRequestHandler to set the ContentType for the REST response to the BinaryContentType from GetRequest_Submit, and set the BinaryContent from GetRequest_Submit as the response to your REST method.

You have now created a REST endpoint (URL) on your own domain to fetch the external document.

That URL to your exposed REST API can then be used in the pdfJS Viewer plugin. 

That would look something like this:

Regards,


Steven

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.