Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing XUL pages

3 views
Skip to first unread message

Georg Maaß

unread,
Mar 7, 2010, 9:11:00 AM3/7/10
to
Hi,

I want to print the manual of my XulRunner application. The manual is
XHTML with embeded IFRAMES containing the original XUL files of the
application. On screen I see the IFRAMES filled with original screens
like screenshots but not as dead as screen shots but clickable with
working functionality. But when I print this manual only the XMTML is
printed, the IFRAMES are printed as empty boxes.

What must I do to get the XUL content inside the IFRAMES printed too?

J Paul Richardson

unread,
Mar 8, 2010, 10:55:33 PM3/8/10
to Georg Maaß, dev-te...@lists.mozilla.org
If I understand what it is that you are doing, then maybe this will
help. If not, well, maybe it'll help someone ;-)

I have a XUL dialog that contains the following iframe:

<iframe id="prnFrame" name="prnFrame" flex="1"
src="file:///tmp/print.html" />

Basically, it loads a Javascript generated HTML file into the iframe.
To print, I set my accept button like this:

ondialogaccept="top.prnFrame.print();"

This prints the contents of the frame with no problems. I tried it with
a single image and with the image embedded into an HTML file. They
printed fine.

Now, if this doesn't work for you (or you are already doing it) then the
problem must be that the call to print is ignoring the embedded iframes
in your manual. To test if this is true, you might try placing a print
link into the manual page(s) and see if that works.

> _______________________________________________
> dev-tech-xul mailing list
> dev-te...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-xul
>

Georg Maaß

unread,
Mar 9, 2010, 4:54:02 AM3/9/10
to
J Paul Richardson wrote:
> If I understand what it is that you are doing, then maybe this will
> help. If not, well, maybe it'll help someone ;-)
>
> I have a XUL dialog that contains the following iframe:
>
> <iframe id="prnFrame" name="prnFrame" flex="1"
> src="file:///tmp/print.html" />

In my case the content of the IFRAME is XUL, I now use following trick.

I scan the window (here variable cw) for all IFRAMES before printing and
dump each into a CANVAS replacing the IFRAME. The CANVAS is printed. So
technically I convert the XUL content of IFRAME to a fully rendered
picture, which is printed without problems.

function printPage()
{
let cw = helpWindow.browser.contentWindow;
if(cw)
{
let imgs = cw.document.body.getElementsByTagName('iframe');
let img = imgs && imgs[0];
while(img)
{
let cnvBuf = cw.document.createElement('canvas');
let imgWin = img.contentWindow;
let w = img.getAttribute('width');
let h = img.getAttribute('height');
cnvBuf.setAttribute('width', w);
cnvBuf.setAttribute('height', h);
let ctx = cnvBuf.getContext("2d");
ctx.drawWindow(imgWin, 0, 0, w, h, "rgb(255,255,255)");
img.parentNode.insertBefore(cnvBuf,img);
img.parentNode.removeChild(img);
img = imgs[0];
}
cw.print();
}
}

0 new messages