PDA

View Full Version : Print contents of a DIV layer


damien
11-14-2002, 08:21 AM
I'm using a series of divs to appear as a layer over an image.
I want the user to be able to print the contents of one of the divs without resorting to using a visible popup window.

Is this possible??

An example of the basic structure of the html...

<div id="MainDivLayer">

<div id"TopImage">Top Banner image</div>

<div id="printdiv">This is the text i want to print</div>

<div id"BottomImage">Bottom Banner image</div>

</div>

Thanks in advance...

Roelf
11-14-2002, 08:33 AM
create a print button/link which triggers a function, in the function: hide all the divs which should not be printed, print the window, show the other divs again

damien
11-14-2002, 08:46 AM
Thanks for that.

Two issues...
One is that I have a large image in the backround (the div appears as a layer on top of this image) which I DON'T want to print.

The other is that the div's contents require a scrollbar and window.print seems to ignore the text that's not visible.

Any ideas??

glenngv
11-14-2002, 08:57 AM
you can set the CSS overflow property to visible so that the scrollbar will be removed and the entire content is displayed.
do this in your print function before printing and just put back that property to auto after printing

Roelf
11-14-2002, 08:58 AM
first issue:
cannot think of a solution,

second issue:
in the process of hiding the other content, resize the div which can be printed to a size so that everything fits on the screen and is printed
<edit>
indeed, that is another possibility glenn
</edit>

glenngv
11-14-2002, 09:13 AM
and i think more doable coz you won't know how much exactly you need the div to resize coz you don't know how long the content is. :)

damien
11-14-2002, 09:27 AM
The div solution sounds great. That will certainly work.

I might just have to load a blank white image in the backround to solve the other issue.

thanks for the help
d