homepage Welcome to WebmasterWorld Guest from 54.242.231.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
Forum Library, Charter, Moderators: not2easy

Site Graphics and Multimedia Design Forum

    
Printing web images
dbcoders




msg:3391217
 4:11 am on Jul 11, 2007 (gmt 0)

How's the best way to print a specific image from a web page? I have this code so far:

<link rel="stylesheet" href="print.css"
type="text/css" media="print" /> in the head section

and a css file with:

body {visibility:hidden;}
.print {visibility:visible;}

I then assigned class="print" to the image, but the entire page still prints.

 

Marshall




msg:3391222
 4:18 am on Jul 11, 2007 (gmt 0)

db,

If I understand correctly, you want to pull one specific image from a page and print it without printing any other images or text.

There are two ways that come to mind. Have the image open in a new window with a normal link saying in effect "click here to print image", or use a script to pull the specific image.

I have a script for pulling elements off a page based on id which you are welcome to. Let me know and I will post it.

Marshall

I forgot that I posted the script once before. It's at [webmasterworld.com...]

[edited by: Marshall at 4:34 am (utc) on July 11, 2007]

Mod Edit: fixed link

[edited by: limbo at 11:19 am (utc) on July 11, 2007]

katana_one




msg:3391461
 12:56 pm on Jul 11, 2007 (gmt 0)

Perhaps if you assign "visibility:hidden" to any <DIV> tags or other elements in the page instead of assigning it to the <body> tag.

For example, you could assign a DIV to each element of the page with a class name of "no_print" and then put the following in your stylesheet:

.no_print {visibility:hidden;}

Kind of clunky, but I think you get the idea.

Or if you already have class names assigned for your "media=screen" CSS file, I would suggest using those names in your print.css file to assign the visibility to, again instead of declaring the <body> tag to be hidden.

I guess it really depends on how much you have going on these pages.

dbcoders




msg:3391613
 3:57 pm on Jul 11, 2007 (gmt 0)

thanks, I will look at these options

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved