74
Views
1
Comments
[PDF Viewer Reactive] Binary Size
pdf-viewer-reactive
Reactive icon
Forge asset by Jay Parnau
Application Type
Reactive

Hello

This component is working well with small pdf but when trying with bigger file nothing is rendering

Do you have encountered this behaviour ?


Kind regards

luc



1.1. Displaying Data on Screens.en-US.pdf
2023-05-03 10-22-17
Victor Salvalagio Pereira

Hello Luc,


I faced this issue a few weeks ago and I was able to fix it. 

Steps: 


- Create the OnReady event in the BinaryPDF block and call OnParametersChanged inside it. 

- Inside OnParametersChanged change the latest Javascript call to this:


// Render big files with blob

const binStr = atob( $parameters.Base64 );

const len = binStr.length;

const arr = new Uint8Array(len);

for (let i = 0; i < len; i++) {

    arr[ i ] = binStr.charCodeAt( i );

}

const blob =  new Blob( [ arr ], { type: 'application/pdf' } );

const url = URL.createObjectURL( blob );


document.getElementById($parameters.iframId).setAttribute("src", URL);


// OLD CODE

//document.getElementById($parameters.iframId).setAttribute("src", "data:application/pdf;base64,"+$parameters.Base64);



With this code the Block can render big PDF files.

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