0

print iframe content

asked 2008-12-23 13:51:22 +0800

nkavuri gravatar image nkavuri
39 1

I have a modal window that contains a link and iframe. When the "Print" link is clicked, I would like to print the content of the iframe. How is this possible ? Please help.

<toolbarbutton label="Print" />
<iframe id="frameContent" width="100%" height="80%"></iframe>

Thank you
Neetu

delete flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2008-12-24 08:50:37 +0800

PeterKuo gravatar image PeterKuo
481 2

I think you can call getContent(), getSrc() of iframe.
And then handle it in java.

link publish delete flag offensive edit

answered 2008-12-24 10:05:45 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Executions.getCurrent().sendRedirect(iframe-src, "_blank");

See http://www.zkoss.org/javadoc/3.5.1/zk/org/zkoss/zk/ui/Execution.html#sendRedirect(java.lang.String,%20java.lang.String)

link publish delete flag offensive edit

answered 2008-12-24 10:20:57 +0800

nkavuri gravatar image nkavuri
39 1

PeterKuo,
I am not sure how I can handle it in Java. Could you please help ?

Henrichen,
Is it possible to do it without opening a new window. I prefer to see a print dialog when I click on the print link. Also, I am not sure how the frame source can be passed as it is dynamic based on a listbox selection and I use the following code to set the frame content.

FileInputStream stream = new FileInputStream(file);
AMedia media = new AMedia(null, null, null, stream);
((Iframe)getFellow("fileContent")).setContent(media);

The file is on the network.

Thank you
Neetu

link publish delete flag offensive edit

answered 2008-12-25 02:46:27 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Neetu,

1. I don't know other ways other than sendRedirect() to "hide" those parts you don't want to print.
2. Since you know where the file is (in server side), you shall be able to give an URL and forward to the file contents.

Here is another thread that discussed print issue. Maybe helpful.

http://www.zkoss.org/forum/index.zul#path%3DlistComment%3BdiscussionId%3D6423%3BcategoryId%3D14%3B

link publish delete flag offensive edit

answered 2008-12-26 00:14:43 +0800

hengsin gravatar image hengsin
39

Hi,

btn.setAction("onclick: frames['" + content.getName() + "'].focus(); frames['" + content.getName() + "'].print()");

Regards,
Low

link publish delete flag offensive edit

answered 2008-12-29 14:14:45 +0800

nkavuri gravatar image nkavuri
39 1

Thanks Low, that helped.

link publish delete flag offensive edit

answered 2008-12-29 14:24:42 +0800

nkavuri gravatar image nkavuri
39 1

OK. Now I ran into another problem with the print button.

The print button and the frame are in a modal window. This modal window is closable and has the onClose event defined as follows.
onClose="self.visible = false; event.stopPropagation();"

I closed the modal window and re-opened it. Nothing happens when I click on the print button.

TIA
Neetu

link publish delete flag offensive edit

answered 2008-12-30 01:38:22 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Neetu,

It would be easier if you can provide a sample testing code. Thanks.

link publish delete flag offensive edit

answered 2008-12-30 02:20:05 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

And sometimes it might be the issue of the browser. Would you test with different browser?

link publish delete flag offensive edit

answered 2009-01-15 15:01:08 +0800

nkavuri gravatar image nkavuri
39 1

Yes, it is a browser issue. Works fine in IE and Safari and doesn't in Firefox.

I will submit it in Bugs section.

Thanks
Neetu

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: 2008-12-23 13:51:22 +0800

Seen: 1,794 times

Last updated: Jan 16 '09

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