Closed Thread Icon

Preserved Topic: Print command (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20972" title="Pages that link to Preserved Topic: Print command (Page 1 of 1)" rel="nofollow" >Preserved Topic: Print command <span class="small">(Page 1 of 1)</span>\

 
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-03-2001 20:14

How do I send a print command from a web page to the users printer.

Say I have some articles on my website that the user might want to print. Can I make a link that they can click on that will send the print command? I assume there is a way, but truly have no idea how.

All help is greatly appriciated as usual.



- Resolutions, Of All My Fruitless Searches -

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-03-2001 21:01

<A HREF="javascriptrint();">Print This!</A>



[This message has been edited by mr.maX (edited 06-03-2001).]

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-03-2001 23:09

Thanks Mr. Max

You make everything seem so simple.



- Resolutions, Of All My Fruitless Searches -

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-04-2001 05:46

Here's one I like to use on my "printer friendly" formatted page.


<script language=JavaScript type=text/javascript>
<!--
function printPage() {
if (window.print) {
agree = confirm('This page has been reformatted for your printer.\nWe recommend you print a copy of it at this time. \n\nOK to print now?');
if (agree) window.print();
}
}
// -->
</script>


Then, in the body tag:
<body onload=printPage()>

So, the user clicks on the "Printer Friendly" link, and it loads a page with this code, which immediately asks them if they want to print.

Then, I use the
onafterprint to redirect them back to the original page.

Something like:


<script language=javascript type=text/javascript>
function postprint(){
history.back();
}
</script>


And then add onafterprint=postprint() to the body tag as well.

Works real nice.

Hope this helps.


linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 06-04-2001 16:16

~salivating~ Examples, please, Mr. Pugzly? I'd love to see that in action.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-04-2001 20:24

Go here: http://www.poisonscribe.com/divisions/communications/ and click on "Printer friendly" link...

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 06-04-2001 20:57

That's classy. I like it. Thanks for sharing.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-04-2001 23:01

Very nice Pugzly

Also, this might seem like a silly question to most, but where did you get those icons. I like them.



- Resolutions, Of All My Fruitless Searches -

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 06-04-2001 23:07

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-05-2001 03:54

Butcher - the little "print" icons and stuff? They're actually just ideas I saw from looking around on other sites. I grabbed some and changed them a little, then used the "theme" to create the ones I still needed. I still have to make a couple more before I finish working on this site. Feel free to grab 'em if ya want.

Oh - and note Mr. Max's awesome breadcrumbs script in action! :-)

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-05-2001 03:57

InI -

I think your referring to the alternate print document. The problem is that that only works in IE, from what I can remember.

Somewhere, I saw something that would render the page into .pdf on the fly, but I can't recall where I saw that. That was pretty slick.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 06-05-2001 09:50

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-05-2001 13:42

You can generate all sorts of files from server-side languages...

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-05-2001 14:13

Yes, I wouldn't mind knowing how to generate .pdf files on the fly using Perl, if it can be done.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-05-2001 14:52

http://search.cpan.org/search?mode=module&query=pdf

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-05-2001 15:23

Isn't there also a way to specify a style sheet to take effect when you're printing? Something like media="print".

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 06-05-2001 16:27

The Perl modules I've seen are wrappers to PDFlib (A C library for creating PDFs). The functions are very low lwvel, so reproducing your slick HTML layout in a PDF would be a real challenge.

I think it would be applicable in an environment where underlying content (represented as XML or something generic) was rendered into output formats on the fly via templates or XSLT, or something.

PHP has pdf functions also, which are wrappers to PDFlib. The upshot is that you'll need to get and install PDFlib and install it prior to building PHP so that you can link against it.

And don't forget about ghostscript. I create my dynamic PDFs by brute force editing of EPS files which I then transform to PDF by calling ghostscript's ps2pdf utility.

If some of you would like to explore this further (any of these approaches), I'm quite interested. The PHP on my host isn't linked against PDFlib, so I can't show off^H^H^H^H^H^H^H^H give examples on my site.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-05-2001 22:34

Thanks Pugzly

I appreciate you sharing! I just might grab your printer icon.


Slime

There's a couple of ways.

You can do it as you suggested by adding another <link rel="yourprint.css"> and putting media="print inside the tag.

Or you can use @import url(yourprint.css) print

The 'print' at the end of that @import statement could be whatever media type you wanted the conditional import for. It could even be for multiple conditions, i.e., @import url(your.css) print, handheld, ect..


- Resolutions, Of All My Fruitless Searches -

[This message has been edited by butcher (edited 06-05-2001).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-05-2001 23:08

Butcher -

No problem. The only other thing I've done with the printer formatted pages is checking the referrer. Since many browsers print the URL of the page at the top or bottom, we were concerned with people then trying to check out the site based on the printed URL, and ending up on a printer page. So we check the document.referrer. If it's not the original format of the same page, it automatically redirects them to the correct page. Does that make sense?

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-06-2001 01:34

Pugzly

Yes it does, it would it be like using a "header(location " in PHP.

Did you consider using CSS for your printer friendly version? I don't know if you were following the thread where Linear mentioned to me about doing that, but it can work nicely. If put your links that run down the left side, and the links and "Top News Stories" at the bottom in their own divs, you could have a <link rel="stylesheet" type="text/css" href="print.css" media="print"> and change the divs to {display: none;}. Although the screen won't change, the content in those divs won't print. It saves you from making separate pages for printing, and saves the user from downloading another page.

Thanks again

<edit>
had to kill an unexpected slimie
</edit>

- Resolutions, Of All My Fruitless Searches -

[This message has been edited by butcher (edited 06-06-2001).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-06-2001 16:07

Yeah, I was watching that thread. We're too far into the format to make that change right now, but we could come back to that. That's pretty interesting, too. I didn't want to have to load another page, but it was easy to setup and add some functionality to.

What I REALLY want to do is learn PHP/mySQL so I can just use that. This template design makes things simpler, but I think having the content in mySQL would make it MUCH easier.

« BackwardsOnwards »

Show Forum Drop Down Menu