printing without the header and footer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

printing without the header and footer

Post by penguinboy »

i want to send a webpage directly to the printer, instead of opening it in the browser and pressing print, its for official forms, and they cannot have headers and footers...
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

I don't think you can do that with php, but using IE5 you can remove the header and footer.
Go to "File" menu and select "Page setup" and make sure header and footer boxes are blank.
seg
Forum Commoner
Posts: 38
Joined: Thu Oct 31, 2002 12:08 pm
Location: Northern, VA
Contact:

Post by seg »

Yeah, if anything, this would be more a job for javascript.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

well...
i don't like java... lol...
and the IE5 thing would work, individually, but I'm not the one using the website, i'm making it for many many clients, it i'm certin that very few of them would understand/want to mess with their printer settings, and it would be a pain to change IE's settings for one website....

and the thing about java is... I don't like the idea that someone may be paying for a service, but not be able to print the offical forms they need because their browser doesn'ts support java, and the only solution to that is if i would provide tech support, and ... i want tech support to be at a minimum
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

what i really want to do is send the user to the official form, then have them click a "print form" link that i made, then instead of printing the webpage, it sends a page directly to the printer, so there's no header or footer.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you wouldn't want all the morons in the world to be able to send documents to your printer without some kind of confirmation (like "really print 150 pages?"), would you? ;)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

That won't be possible - think about the possible consequences if it was and malicious site owners sent 100's of pages to your printer...

You either need to post instructions telling the users how to stop headers and footers from printing or provide the form in a different format like pdf that users can download and print without you having to worry about webpage headers and footers. That is of course unless there's a way for javascript to set empty headers and footers.

Mac
seg
Forum Commoner
Posts: 38
Joined: Thu Oct 31, 2002 12:08 pm
Location: Northern, VA
Contact:

Post by seg »

penguinboy wrote:well...
i don't like java... lol...
Ja, I agree 1000%, that's why I work with PHP. :)
One thing you might want to try is provide a link for a printer-friendly version. Perhaps a text only version, or you could use PHP to do something like this
url.com/file.html?version=printer

if version = printer then display the page without footer or header. If the footer and header are included as part of the page, then a simple if,then,else statement would provide the means to exclude them for the printer friendly version. If this is not possible, and you wanted to somehow force a print and control what is and is not printed then a client-side language is in order, namely java. But then we go back to the whole thing of Java sucking goat balls.

edit: any btw, the only way to print via a link on a webpage is via java or vb.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

[quote="twigletmac"]That won't be possible - think about the possible consequences if it was and malicious site owners sent 100's of pages to your printer...

You either need to post instructions telling the users how to stop headers and footers from printing or provide the form in a different format like pdf that users can download and print without you having to worry about webpage headers and footers. That is of course unless there's a way for javascript to set empty headers and footers.

Mac[/quote]

[edit]
woops, mis read what you said there. I see your point. Damn malicious people... always ruining it for me.... lol.
[/edit]

I hadn't thought about using a pdf, i'll have to look into it


but what i was really wanting was something like what seg wrote

[quote="seg"]if version = printer then display the page without footer or header. If the footer and header are included as part of the page, then a simple if,then,else statement would provide the means to exclude them for the printer friendly version. [/quote]

[edit]
this is going to be a real problem though, i'm offering these clients a web based service that they normally would do on a windoze exe, so when i started this project this problem never came up. I'll do some brain storming, thanks for the imput guys.[/edit]
Last edited by penguinboy on Fri Nov 08, 2002 10:01 am, edited 1 time in total.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

thanks

Post by penguinboy »

but anyway, thanks for the replies guys, helping me narrow down my options.

-pb
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Posted by "seg"
if version = printer then display the page without footer or header
Unfortunately, header and footer are not part of the page, they are added by the browser printing process.

I have the same problem on one of my client's sites. The form is generated dynamically from a database, so a pdf or the like is not feasible.

My user either has to reset his browser of live with the header and footer.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

seg wrote:
penguinboy wrote:well...
i don't like java... lol...
Ja, I agree 1000%, that's why I work with PHP. :)
PHP and Javascript do two entirely different things, not liking javascript is irrelevant as to why you would work with PHP.
seg wrote: somehow force a print and control what is and is not printed then a client-side language is in order, namely java. But then we go back to the whole thing of Java sucking goat balls.

edit: any btw, the only way to print via a link on a webpage is via java or vb.
Well, if its the only way to do it, but you don't like it, then I guess that's tough <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> eh?

Don't take this personally, but it just <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> me off when people say they use php because they don't like things like javascript. Or even worse, they say they hate javascript because 'its used to make stuff like pop-ups'... Okay, well thats like saying "i hate guns"... people may do bad stuff with them, but they sure as hell save your ass alot.
User avatar
cybaf
Forum Commoner
Posts: 89
Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden

Post by cybaf »

hob_goblin:
I agree totally with what you are saying... making a good website without javascript is basically impossible. I also think that people should know the BIG difference between Java and javascript...:)

ok ok...

well back to the topic...

penguinboy: The best solution for this would no doubt be using pdf. Look into the options of using php to generate pdf's. Then you'll have total controll of what comes out to the users printer...

//Anders
seg
Forum Commoner
Posts: 38
Joined: Thu Oct 31, 2002 12:08 pm
Location: Northern, VA
Contact:

Post by seg »

I hate to take this route, but the child in me is pushing me to reply...
hob_goblin wrote:PHP and Javascript do two entirely different things, not liking javascript is irrelevant as to why you would work with PHP.
My opinions are not something you are qualified to comment on. My displeasure with JavaScript comes mostly from the fact that it is most times poorly written, its nature is poorly conceived, and the security risks that malicious programmers have created makes it, in my opinion, one of the worst languages in existence today. I don’t like what it has become. Even if it had not become such a popular venue for crackers it’s ultimately self-defeating to create something that relies on the user in order to work.

Besides, PHP and MySQL can do just about anything JavaScript can do aside from Java applets; same with ASP vs. PHP.
hob_goblin wrote: Don't take this personally, but it just <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> me off when people say they use php because they don't like things like javascript. Or even worse, they say they hate javascript because 'its used to make stuff like pop-ups'... Okay, well thats like saying "i hate guns"... people may do bad stuff with them, but they sure as hell save your ass alot.
I know you’d like to believe my animosity towards JavaScript was that simple and ignorant. I don’t take what you say personally, just like I don’t expect you to take it personally when I say you are a friggin asshat. JavaScript is the only thing Sun ever made that I have a grudge against. Java itself is a nice language, when kept on the server-side, but there in lies the key. JavaScript is browser reliant. PHP, Java, CGI, etc. rely on the server. I don’t like any code that makes it 10 times harder to create web-based tools. For the most part, server-side languages are ‘code-and-forget’, i.e. code for one user and it works for all. For the record, I’m not too thrilled with cookies either, but that just falls into the same category as browser-reliant code.

And from now on if you want to flame me, do it via private message. I’m in the wrong just as much as you are now, but like I said, the part of me that still longs to be immature gets the better of me sometimes. My apologies to the thread.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Further to what cybaf said (as it may have got a little lost in the Javascript debate) it is possible to dynamically generate pdf's using PHP have a look at http://www.php.net/manual/en/ref.pdf.php.

IMHO, pdf's look more professional (and give you more control) than plain old web pages for what you're trying to achieve.

Mac
Post Reply