print out a file to default printer???

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
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

print out a file to default printer???

Post by zinc »

hi....

as mentioned in the subject, are there any ways to allow to a user to click on a file link and automatically print out to a default printer using php????

thx....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: print out a file to default printer???

Post by Chris Corbyn »

zinc wrote:hi....

as mentioned in the subject, are there any ways to allow to a user to click on a file link and automatically print out to a default printer using php????

thx....
No. PHP runs on the server not the client.

You can use javascript to bring up the print dialog but you can't change the printer:

Code: Select all

window.print();
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

Post by zinc »

thx for the help
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you can dynamically generate a pdf document with auto print set to on, automatically open it and it will print.. which is basically what you are trying to achieve.
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

Post by zinc »

Jcart wrote:you can dynamically generate a pdf document with auto print set to on, automatically open it and it will print.. which is basically what you are trying to achieve.
hi...i dun quite get what u mean......cos the files are supposed to by uploaded by some users and the files can be in different format...
ie jpeg, gif, docs, txt etc
so another person maybe like the administratior of the site wants to print out the file directly ......

i dun understand wat u meant by dynamically generate a pdf document....

thx
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

zinc's last post for non-aolspeakers

Post by feyd »

zinc wrote:hi...i don't quite get what you mean......because the files are supposed to by uploaded by some users and the files can be in different format...
ie jpeg, gif, docs, txt etc
so another person maybe like the administratior of the site wants to print out the file directly ......

i don't understand what you meant by dynamically generate a pdf document....

thanks
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

Post by zinc »

sorry for the language
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

because the files are supposed to by uploaded by some users and the files can be in different format...
ie jpeg, gif, docs, txt etc
so another person maybe like the administratior of the site wants to print out the file directly ......
You can simply take the uploaded image and create a pdf document containing the image. The reason why you want to use a pdf document is you will have more control of printing. http://php.net/pdf is a good start
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

Post by zinc »

thanks for the help....
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

It's possible to automatically print HTML using the default printer too if you're happy with it only working in IE .. and you're happy using some nasty ActiveX ..

Code: Select all

<html>
<head>
<script>
function ieExecWB( intOLEcmd, intOLEparam )
{
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1 ) )
		intOLEparam = 1;
	WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
	WebBrowser1.outerHTML = "";
}
</script>
</head>
<body>
Boo!
<input type="button" value="Print" onClick="ieExecWB(6, -1);">
</body>
</html>
zinc
Forum Newbie
Posts: 15
Joined: Fri Feb 10, 2006 1:02 am

Post by zinc »

onion2k wrote:It's possible to automatically print HTML using the default printer too if you're happy with it only working in IE .. and you're happy using some nasty ActiveX ..

Code: Select all

<html>
<head>
<script>
function ieExecWB( intOLEcmd, intOLEparam )
{
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1 ) )
		intOLEparam = 1;
	WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
	WebBrowser1.outerHTML = "";
}
</script>
</head>
<body>
Boo!
<input type="button" value="Print" onClick="ieExecWB(6, -1);">
</body>
</html>
thx for help but there is no possibility for me to limit the user's perference..........whether its IE or FF or Opera.....

but i got another question ....not too sure if it should be place under here...
its with regards to html....

how do i insert a newline using html tool tip???

Code: Select all

<a href=# title="Free DHTML and JavaScripts">
i need to break into a new line.....above shown is just a example....tried using <br> and it doesn't work.....
googled but unable to find .....found one site that says use LF of ctrl LF, but how do go about using it??
LF stands for NL line feed, new line in the ascii table..

when i use enter to go to newline for the title, it works for IE but not for FF....are there any other ways for it to work for FF??

thanks
Post Reply