473,756 Members | 3,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help Me Understand A Printer-Friendly CSS....


Okay, I'd like to create a print-friendly website, so I've been
reading up on how to create print-friendly pages (without duplicating
my site, of course, by having separate versions of each page)....

Apparently one can use JavaScript or CSS for this....

Using CSS, it seems that the "trick" is to use * media="print" * in
the <linktag....

So if I have a hyperlink to a print-friendly page...um, well, what's
that, just the current webpage, only with "print.css" instead of
"default.cs s" in the <linktag??? If so, that would be just having a
duplicate copy of the whole site!

So that can't be how it works, right?

But then, how does it work??

What's that print-friendly hyperlink actually pointing to??

This must be so basic that no one bothers explaining it...but I'm
starting ~95% from scratch, here....

BTW, here's something from my print.css file that's not working for
some reason:

body {
background-color: #fff;
color: #000;
margin: 0;
padding: 40px;
font: normal 12pt/160% Georgia;
}

#header, #menu, #search, #footer {
display: none;
}

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
}

img { display: none; }
That last img thinggy, I'm not so sure about, as well the show URL
thinggy right before it, but the others don't work and yet they look
100% proper to me! What's going on?? My footer still shows up, my
menu shows up, the searchbox shows up, hyperlinks are still underlined
and colored, etc.

ALL ADVICE MUCH APPRECIATED!!
Jun 27 '08
15 2186
Prisoner at War wrote:
I was wondering if there's a way to give the user a WYSISYG page, a
preview of the printout, independent of the operating system's own
print preview capability...ap parently it's possible; I'm getting the
Yeah, with most moder browser they have a "Print Preview" button. The
print stylesheet will be used to create the preview page, so there is
not need to duplicate this on your part...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jun 27 '08 #11
On Apr 20, 6:22 pm, "Jonathan N. Little" <lws4...@centra l.netwrote:
>

Yeah, with most moder browser they have a "Print Preview" button. The
print stylesheet will be used to create the preview page, so there is
not need to duplicate this on your part...
Okay, I guess my question is "academic" or "moot" at this point, but
for the sake of intellectual curiosity I must reiterate: it was,
apparently, possible to get CSS to generate a webpage based on an
existing webpage.

So forget the "print-friendly" business, then, and let me ask: how
does one use CSS to generate another page based on one currently
viewed??

Again, I'm getting this notion from Simon Collison's 2006 "Beginning
CSS Web Development," page 323-4, if I'm reading it right (he even has
before-and-after photos of http://www.science-city.co.uk as
"proof")... .
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIOhttp://www.LittleWorks Studio.com
Jun 27 '08 #12
Prisoner at War <pr************ *@yahoo.comwrit es:
On Apr 20, 3:33 pm, Ed Mullen <e...@edmullen. netwrote:
>Prisoner at War wrote:

<SNIP>

Looking more closely I'm perplexed by that construct. Where's you get that?
#primarycontain er a:after {
content: " ( attr(href) ")";
This is (intended to be) CSS3 and should probably read:

content: " (" attr(href) ")";

No idea if there is any browser support for it yet. It seems
premature to suggesting as a solution to any real problem.
font-size: 11pt;

You got me on that construct. Never seen such a thing.

It's from Simon Collison's "Beginning CSS Web Development: From Novice
to Professional" (2006, Apress)...he doesn't explain it much since
it's on pages 323-4 and so probably assumes a high level of technical
know-how by then...
Acquired how? By reading someone else's book on CSS? A technical
book should explain its content -- you are being too kind in letting
the author off the hook.

BTW, on the whole "WISIWTG print version" thing, simply forget it.
Any link to such a thing is just a hack from the last century and the
attempt to anything in a browser that even gets close to the browser's
print preview in terms of accuracy or usefulness is doomed to
failure. Do the print media CSS, by all means, but what else could
you usefully add?

--
Ben.
Jun 27 '08 #13
On Apr 20, 7:37 pm, Ben Bacarisse <ben.use...@bsb .me.ukwrote:
>

This is (intended to be) CSS3 and should probably read:

content: " (" attr(href) ")";
Okay, to quote the book (pages 323-4):

It is...useful to actually print the URLs alongside mentioned websites
in certain sections of the page. Earlier we looked at how CSS can
generate content before and after an element using CSS pseudo-
elements...here , the :after pseudo-element is used to perform a
specific function after each hyperlink...we are targeting the
[primarycontaine r] column, ensuring links outside of this column are
not printed. Next, the selector seeks any links in this column as the
<aelement is declared. Finally, the :after pseudo-element is
declared, informing the browser that any links within the
[primarycontaine r] column are where this action should happen. The
value declared for the content property is a little more complex, but
it basically tells the browser to perform the action immediately after
the content, which is the attribute href, and to place the generated
content within brackets (which have to be surrounded with quotes)....
No idea if there is any browser support for it yet. It seems
premature to suggesting as a solution to any real problem.
Thing is, the book's copyrighted 2006! That must mean he wrote it in
2005!!
Acquired how? By reading someone else's book on CSS? A technical
book should explain its content -- you are being too kind in letting
the author off the hook.
I think technical books, even if they aren't meant to be strictly
reference texts, ought to have each section be more "self-contained"
than not, but seeing how I've just started the book yesterday and am
already skimming ahead to Chapter 14 out of like 16 altogether, I just
can't say if anyone's at "fault" here.
BTW, on the whole "WISIWTG print version" thing, simply forget it.
Any link to such a thing is just a hack from the last century and the
attempt to anything in a browser that even gets close to the browser's
print preview in terms of accuracy or usefulness is doomed to
failure. Do the print media CSS, by all means, but what else could
you usefully add?
Ah, well, since I'm just learning right now, it's all very interesting
just for something to be possible, whatever its utility! I mean, one
could also include "javascript:sel f.print()" in a "print this"
hyperlink even though practically everyone would know how to print a
webpage...but it was very interesting in itself to know that such a
thing can be done.
--
Ben.
Jun 27 '08 #14
Prisoner at War <pr************ *@yahoo.comwrit es:
On Apr 20, 7:37 pm, Ben Bacarisse <ben.use...@bsb .me.ukwrote:
>>
This is (intended to be) CSS3 and should probably read:

content: " (" attr(href) ")";

Okay, to quote the book (pages 323-4):
No, you are quite right. I misread a document title! The attr()
syntax is in CSS 2 and 2.1. IE6 support is missing (which why one
does not see this used much) but that does not mean it is not
"current" CSS.

<snip>
Thing is, the book's copyrighted 2006! That must mean he wrote it in
2005!!
OK, but there were drafts of lots of CSS3 before then. No excuse for
my getting it wrong, but the date is not the issue.

<snip>
Ah, well, since I'm just learning right now, it's all very interesting
just for something to be possible, whatever its utility! I mean, one
could also include "javascript:sel f.print()" in a "print this"
hyperlink even though practically everyone would know how to print a
webpage...but it was very interesting in itself to know that such a
thing can be done.
The problem is the whole idea of "such a thing" (WYSIWYG print preview
in browser window). It is ill-defined and even those bits where one
can make a stab at defining the "expected" behaviour, CSS has no hope
of even getting close to doing it.

Even the rather limited "change the page so links include the text of
the href attribute" can't be done in a cross-browser way (yet).

--
Ben.
Jun 27 '08 #15
On Apr 20, 8:36 pm, Ben Bacarisse <ben.use...@bsb .me.ukwrote:
>

<SNIP>

The problem is the whole idea of "such a thing" (WYSIWYG print preview
in browser window). It is ill-defined and even those bits where one
can make a stab at defining the "expected" behaviour, CSS has no hope
of even getting close to doing it.

Even the rather limited "change the page so links include the text of
the href attribute" can't be done in a cross-browser way (yet).
Well, that's precisely the matter at hand: can it, or not? The book
seems to say it's possible...I mean, it had two pictures of the site,
a before and after, both within the Apple Safari web browser (though,
curiously, no URL field), which seems to suggest such a WYSIWYG page
possible. So I'm really puzzled how that could be, how CSS could be
used to generate a page based on another page.

If it's actually not possible, then those two photos were really
misleading, especially in their before-and-after placement. Being
inside browser windows, it seemed to suggest that the code the author
provided could "dynamicall y" create a "stand-alone" WYSIWYG print-page
in the browser....

Ugh, I think I will just go back to website content-creation as
opposed to structural-construction and tweaking...bleh ....
--
Ben.
Jun 27 '08 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9275
by: whirl | last post by:
Hi. I really need some help on this one please. I am trying to print a 12.1 x 12.1cm box to my printer. I have found this code bit I just cant work out what the numbers mean. I know they are something to do with X/Y coordinates but what do the values actually mean . Printer.Line (1000, 2000)-(5000, 4000), vbRed, B
3
2979
by: Mahmood Ahmad | last post by:
Hello, I have written a program that reads three types of records, validates them acording to certain requirements and writes the valid records into a binary file. The invalid records are supposed to be reported on the printer but I have commented those pieces of code and have got those records printed on the screen. I am using Microsoft Visual C++ 6.0 on Microsoft XP (Home) platform. I am facing some problems in getting desire...
5
3355
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this printer using a RawPrinterHelper class that i found I believe in the msdn. the class works wonderfully when I send stright text data (in the correctly formated string that the sato printer requires.) but when i go to send a image nothing is...
2
3210
by: PC User | last post by:
I found some VB code to printout a richtext field and I'm trying to adapt it to MS Access 2000. I think there might be some small changes to make the adaption between VB versions. Also my OS is Windows XP. The website I found the code is: http://www.developerfusion.com/show/244/ See the code below. There is also some code found at http://www.freevbcode.com/ShowCode.asp?ID=1028 I would appreciate someone's help in getting this to work. ...
0
1343
by: chunming | last post by:
hi, Dear Leader(i think you are enough for my project leader), I have a very fancy question and I need your help: I use C#.net to develop a Point of Sales system, use Epson Tm-t88 printer( POS printer), connected w/ :LPT1, and now: I have following problem: when i finished installing the driver, the test page is ok If I use notepad to print something by choose this printer in printer dialog, it works fine,
3
1427
by: trint | last post by:
Here is the error: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: Not found here is the code: string printerName = ""; foreach (ManagementObject printer in searcher.Get()) {
0
1127
by: Anthony Nystrom | last post by:
I am having trouble with changing printer settings before I raise either the pagesetup dialog or the print preview dialog... Changing the printer name is easy, but I am also trying to change the paper size.... This particular paper size is 30386 Video Top is specific to the printer driver itself... Any sample code as to how to both change the printer and paper size as well as oriention so that the user doesn't have to? This particular printer...
11
9897
by: pamelafluente | last post by:
I am doing my own PrintDialog, and have placed there a combo with the printer names, as in the PrintDialog provided by VB.NET. Here is the question: how do I open the native windows printer dialog for the current printer, so that my current PrintDocument.PrinterSettings will be set according to the User choices ? Thanks -Pamela
13
1818
by: robert10 | last post by:
Hi, I have recently added some code to my form in regards to resizing an image on Print. I have an image that does print correctly after its been resized, howver i'm needing to use it as a backgound image which will have variable text written in front of it. I am having trouble geting labels and text boxes to print, along with the inlarged image that is printing. The labels and text boxes need to appear infront of the image. And where do I...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.