简体   繁体   中英

Javascript: Docusign PDF download - How display the downloaded PDF

I'm implementing an ASP api to do all Docusign API flow (get Login information, get the token, send an envelope to be signed, download a envelope document). Now I'm trying to display a downloaded document in the browser and the document is blank. I'm receiving the document byte content from docusign and trying to render it in a iFrame.

the PDF content sent by docusign is like

%PDF-1.4
%?%Writing objects...

and I have an iframe like this

<iframe name="loadDoc" frameborder="1" height="200" width="800"></iframe>

and I have the following js function:

    var htmlText = '<embed width=100% height=100%'
                + ' type="application/pdf"'
                + ' src="data:application/pdf,'
                + PDFdata
                + '"></embed>';


var ifrm = window.frames['loadDoc'].document;
    ifrm.open();
    ifrm.write(htmlText);
    ifrm.close();

how can I get this content and display correctly the PDF content in the iFrame?

Update

If the document has more than 1 page, it's possible to see all pages, all blank...

You send the PDF to the user's browser and it's the browser's responsibility to show it to the user. This is outside of your control. If you want a better experience, you can use the DocuSign embedded viewer to show the document to the user as they saw it during signing. This is the same as embedded signing, but for a complete document and it would show the entire document in the browser. You would have to make the API call to generate a URL for embedded viewing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM