How to render a file in a frame?

I consume a service that returns a PDF file, I have a web application that currently I do a Windows open on the service call and downloads the file.

But I now need to render this file to be able to generate the automatic printing of it.

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

My code is window.open (url)

Author: Jéssica Neves Machado, 2018-01-12

1 answers

You can use a PDF renderer fully written in HTML5 / JavaScript (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 printing).

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

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

window.open('viewer.html?file=ARQUIVO_PDF.pdf','_blank','width=1000, height=500');
 0
Author: Sam, 2018-01-13 23:29:36