How to render a file in a frame?

Asked

Viewed 184 times

1

I consume a service that returns a PDF file, I have a web application that I currently give a Windows open in the service call and download the file.

But now I need to render this file in order to generate its automatic printing.

Does anyone know how I can render this file by an Ajax or frame request? In order to try somehow print?

my code is window.open(url)

  • Welcome home, I could edit your question and put the code you have tried to do ? Or a MCVE? Also enjoy and do the Tour to learn more about the community.

  • Not always will the browser allow you to show the pdf embedded in the page.

1 answer

0

You can use a fully HTML5/Javascript PDF renderer (does not use external libraries or frameworks) and compatible with all modern browsers called pdf.js. In addition to displaying the PDF on the page, it has many features (including print).

You can download the package directly on the component page: http://mozilla.github.io/pdf.js/

When uploading the component files to the server, there is a file called viewer.html inside the briefcase web rendering the PDF. You can call this file via window.open sending in the URL the parameter ?file with the PDF name you want to open. Example:

window.open('viewer.html?file=ARQUIVO_PDF.pdf','_blank','width=1000, height=500');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.