Access Printer through PHP

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
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Access Printer through PHP

Post by vinoth »

hi all

Is there any possible to print the current PHP page in papers
How can I achieve this..

I need some code, suggestions regarding this

Thanks in adance
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post by Steve Mellor »

PHP doesn't really have the device control you're looking for. I would suggest looking at Javascript to print off a page.

Code: Select all

<a href="javascript:print()">PRINT THIS PAGE!</a>
Of course, being javascript you can call it whenever you like. A good solution I have used before is to make an i-frame on the page (1px X 1px) and load the page you want to print into that frame, that way you can use a separate page and have more control about which pictures are printed and where your line-breaks are.

Take a look at this:

http://www.htmlgoodies.com/beyond/css/a ... hp/3470341

for more information...
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

is it any possible to print the particular Particular field instead of printing the entire web page
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post by Steve Mellor »

once again, I would load what you want to print in to a new page (in an i-frame) and then print that. It will give you much less trouble.
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

You can use special CSS for printing.
Also to print part of page - make special page for printing :)
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

how can I use CSS for printing alone,
Is it possible?
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

Yes.
This is nice short tutorial http://www.alistapart.com/stories/goingtoprint/
Post Reply