I am trying to display in a screen a pdf that is stored in a db table.
I tried to pass the url of a REST that returns the pdf content as a binary but didn't work. Is there a way of achieve what i want?
Hi André,
You can preview a PDF file in react apps using an iframe:
For this, you need to convert your binary to Base64 using this function:
Regards,
Paulo
@Paulo CaĂ§Ă£o I did that and now i'm getting this error:
Can you share your oml?
No I can't.
Basically what i am doing is using a data action to get the binary and converting it to base64 and then pass it to the iframe.
Hi, you need to add the base64 prefix:
I did this but continues without working. Shows the same error...
did u get the solution for this.can u share oml
Hi there, I now that 2 years passed, but I've implemented this component with binary option.
Using JS I create a Blob and create a URL for it, feeding the component. Code bellow:
var byteCharacters = atob($parameters.Base64);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);}
var byteArray = new Uint8Array(byteNumbers);
var file = new Blob([byteArray], { type: 'application/pdf;base64' });
$parameters.NewURL = URL.createObjectURL(file);
That code is placed on the top of the OnInitialize with a assign right after it, setting the JS Output to the existing URL input parameter (I've converted it to local variable).
Hope it helps