How to display PDF File in binary data into browser?
Question

I have done this before and used my old code as reference to replicate it, but when I try to use the same code, it doesn't seem to work.
Here is my code:

Here are the variables:

UserSelect:

IFrameHTML:

PointerEvents:

HTMLPDF:


The file that is uploaded into the database is a PDF file and retrieve it in binary data.

Solution

Hello Wilbye,

If I understand your question well then,

I hope below forge component will meet your requirement.

https://www.outsystems.com/forge/component-overview/3526/simpleviewer


You can achieve this with javascript also,

https://stackoverflow.com/questions/65533934/showing-binary-pdf-in-browser-javascript

Regards,

Ajit Kurane.

mvp_badge
MVP

Hi Willbye,


In which type of application are you working on? Reactive / Mobile or Traditional Web?


If you are working on Reactive / Mobile applications, you can try the HTML Document Viewer forge component, which also includes a demo on how to display the different types of document, including PDF.

If you are working on a Traditional Web application, you can use the pdfJS Viewer forge component, which also includes a demo.


Kind Regards,
João

Hello Joao -

pdfJS Viewer forge component only display pdf which is stored in fileserver. I could not find code or example where it can data from binary. 

Thanks

Hi @Wilbye Descalsota - Did you find how to embed pdf from binary source in traditional app?

Solution

Hello Wilbye,

If I understand your question well then,

I hope below forge component will meet your requirement.

https://www.outsystems.com/forge/component-overview/3526/simpleviewer


You can achieve this with javascript also,

https://stackoverflow.com/questions/65533934/showing-binary-pdf-in-browser-javascript

Regards,

Ajit Kurane.

Hi,

the most simple way and without an additional component and/or javascript is.

Convert the Binary Data Content to Base64 with BinaryToBase64 server action.

Add an embed html element to your page with the following options


You should wrap that embed in an if, so that it is only display when the variable that holds your Base64 text string has a value. eg If(PdfBase64Text <> "")

Best

Stefan

Many Thanks! Suggestions on this thread was very helpfull. I have used simple viewer as suggested by Ajit and I was successfully able to display pdf from binary data stored in database. 

I am glad that I could help you.

Have a great day!!

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