Overlaying text on printable image |
Overlaying text on printable image |
Rich Pasco |
Feb 10 2007, 06:21 PM
Post
#1
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
I want to overlay text and a transparent GIF image so that when the user prints the web page it prints as displayed.
(The image is an artiistic border for a coupon; the text gives the details of the offer in the middle.) Problem is, if I declare the image as background="myimage.gif" then by default most browsers don't print the image. If I declare the image as foreground with img src="myimage.gif" then I don't know how to overlay it and the text. Can I do this with straight HTML? If not, can I do it with CSS? How? Thanks in advance, - Rich |
pandy |
Feb 10 2007, 07:06 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
CSS. There are serveral ways (read about CSS positioning) but I'll show you one.
Let's say the image is 500 pixels tall and you want the text to start 50 pixels from the top and 30 pixels from the left edge. CSS: CODE #coupon p { margin: -450px auto auto 30px } /* that's top, right, bottom and left margin - in that order */ HTML: HTML <div id="coupon"> <img src="couponborder.gif" width="500" height="500"> <p> Blah bla yadda yadda</p> </div> A negative margin moves the box in that direction. The rest is pure math based in the image. |
Rich Pasco |
Feb 11 2007, 10:44 AM
Post
#3
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
Thanks, pandy!
I found a similar approach here: http://willmaster.com/possibilities/archiv...030902001.shtml Between your suggestion and that page, I should be able to work it out. - Rich |
Rich Pasco |
Feb 12 2007, 04:07 PM
Post
#4
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
Thanks to those who helped, the finished product is here:
http://www.michelespizzeria.com/coupons.shtml - Rich |
Darin McGrew |
Feb 12 2007, 04:31 PM
Post
#5
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
FWIW, the coupon text starts overlapping when my browser enforces a minimum font size of 22px or larger. (I normally enforce a minimum font size of 12px, but I was curious what would happen...)
|
Frederiek |
Feb 13 2007, 06:25 AM
Post
#6
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
BTW, you have at least to set units to your attribute values in your coupons.css.
|
Rich Pasco |
Feb 13 2007, 10:01 AM
Post
#7
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
FWIW, the coupon text starts overlapping when my browser enforces a minimum font size of 22px or larger. (I normally enforce a minimum font size of 12px, but I was curious what would happen...) Thanks, Drew. I'm aware of that problem, but I don't see an easy solution. Do you? For reasons like that, I'm not entirely satisfied with my approach of overlaying HTML text onto the GIF artwork. I considered making each entire coupon as a single GIF (all graphics, no text). But besides being harder to update content (it would require regenerating the GIF each time the coupon content changes), the graphic text would then print jaggy and fuzzy compared to the HTML text (which prints neatly in TrueType or PostScipt fonts). Any ideas? - Rich |
pandy |
Feb 13 2007, 10:09 AM
Post
#8
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
What if you use a print style sheet and set the text in pixels or points only for print? Would that work?
I get a JavaScript error on the printer friendly page in IE and Opera tries to print the page as soon as it loads. But maybe that's the intention? |
Rich Pasco |
Feb 13 2007, 10:35 AM
Post
#9
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
|
Rich Pasco |
Feb 13 2007, 10:52 AM
Post
#10
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
I get a JavaScript error on the printer friendly page in IE and Opera tries to print the page as soon as it loads. But maybe that's the intention? What JavaSciript error do you get? I open it in MSIE 6.0 and 7.0 and don't see a Javascript error. Or maybe I'm not looking in the right place. The intention is to open a printer dialog as soon as the page opens, if possible. |
Frederiek |
Feb 13 2007, 10:54 AM
Post
#11
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
QUOTE The format of a length value (denoted by <length> in this specification) is a <number> (with or without a decimal point) immediately followed by a unit identifier (e.g., px, em, etc.). After a zero length, the unit identifier is optional. From CSS 2.1 Chapter 4.3 Values/4.3.2 Lengths. |
Frederiek |
Feb 13 2007, 11:01 AM
Post
#12
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
No javascript error in Safari either.
The print dialog does open upon clicking the printer friendly coupons link. But then it seems to me, you don't need to repeat the print this page in the pop-up. |
Darin McGrew |
Feb 13 2007, 11:11 AM
Post
#13
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE I'm not entirely satisfied with my approach of overlaying HTML text onto the GIF artwork. Here are several possible approaches:
|
Rich Pasco |
Feb 13 2007, 11:39 AM
Post
#14
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
Thanks, Darin. I appreciate all the alternatives.
A design goal was for the web page to display the coupons in the context of the web site (logo header, sidebar table of contents, etc.), which rules out PDF without a lot of duplication of artwork. Of course the "printer friendly" page is the same coupons without the periphery. It would be nice if a small PDF graphic could be embedded in a box on a larger HTML page (like we do with GIF, JPEG, PNG now) but I don't think that's possible. Another goal was to make the coupon text editable by the non-technical pizzeria manager via an HTML form. It's easy if it's part of an HTML file, but harder if it's part of an image (which would require server-side code to rasterize the text). I can't depend on CSS2 since few browsers in the field support it. The rounded corners trick you linked depends on generated content ('::before' and '::after') which isn't supported on MSIE 6 or 7. Anyway the pizzeria manager is happy with the coupons as they look. Since few users (perhaps just visually impaired ones) run their browsers with grossly non-standard font sizes the coupons will work for most ci This post has been edited by Rich Pasco: Feb 13 2007, 11:49 AM |
Rich Pasco |
Feb 13 2007, 11:42 AM
Post
#15
|
Group: Members Posts: 8 Joined: 10-February 07 From: San Jose CA & Land O Lakes FL Member No.: 1,852 |
|
Lo-Fi Version | Time is now: 26th April 2024 - 01:30 PM |