0

I would like to preview a pdf document, in-browser if possible.

asked 2012-12-11 18:34:30 +0800

javikin gravatar image javikin flag of Mexico
45 2
http://www.yellowme.mx/

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.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-12-11 19:22:42 +0800

jj gravatar image jj
638 3

javaikin,
I don't have an answer, but I am wondering whether you could share your PDF print javascript.
I am facing the same issue, but my print javascript doesn't seem to work on Chrome or firefox.

Thanks.

-JJ

link publish delete flag offensive edit

answered 2012-12-12 19:13:31 +0800

javikin gravatar image javikin flag of Mexico
45 2
http://www.yellowme.mx/

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

link publish delete flag offensive edit

answered 2012-12-13 05:19:49 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2625 3 8
http://emrpms.blogspot.in...

Look at the ZK Sample 2 application.

link publish delete flag offensive edit

answered 2012-12-13 06:22:06 +0800

jj gravatar image jj
638 3

@javikin,
Thanks for sharing. I tried something very similar to your approach, and I even tried Object/Embed tags. The only difference was that I was using pure javascript and servlet. I'll try out yours.

link publish delete flag offensive edit

answered 2012-12-13 17:30:43 +0800

javikin gravatar image javikin flag of Mexico
45 2
http://www.yellowme.mx/

@jj
Let me know what happens.


@Senthilchettyin
I try with the ZK Sample 2 and i have the same problem:

Imagen

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-12-11 18:34:30 +0800

Seen: 81 times

Last updated: Dec 13 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More