-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I would like to preview a pdf document, in-browser if possible.
Right now my solution uses an iframe to preview it, then I send it to print using Javascript. This seems to work fine on chrome and safari (given they have already a previewer), but it won't work on other explorers (firefox, ie).
On other broswers, it prompts you to download the pdf, and when I try to print with JS it won't work because I use the iframe to do so.
Sure, first you need display you pdf inside a control, for this i use a iframe, some like this:
<iframe id="idIFrame" name="iframeName" onCreate="pdfController.loadPDF(self);" width="800px" height="1200px" />
The controller only need do this:
Media m;// conde for create or load the pdf file iframe.setContent(m);
With this, you can see a preview in your page, then with JS you can send to print the iframe with this:
<button_print xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="iframeName.print();" />
I hope you find it useful
Look at the ZK Sample 2 application.
@jj
Let me know what happens.
@Senthilchettyin
I try with the ZK Sample 2 and i have the same problem:
Asked: 2012-12-11 18:34:30 +0800
Seen: 81 times
Last updated: Dec 13 '12