PHP printing problem

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
lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

PHP printing problem

Post by lazaroskyr »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


My php version is 5.1.6 and OS is WinXP.The printer is OKI microline3321 dot matrix.Here is the code:

Code: Select all

$handle = printer_open("ML3321");
printer_set_option($handle,PRINTER_ORIENTATION,PRINTER_ORIENTATION_LANDSCAPE);
printer_set_option($handle,PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM);
printer_set_option($handle,PRINTER_PAPER_WIDTH,320);
printer_set_option($handle,PRINTER_PAPER_LENGTH,250);
printer_start_doc($handle,"PHP printing test");
$font = printer_create_font("Arial", 10, 7, PRINTER_FW_NORMAL,false, false, false, 0);
printer_select_font($handle, $font);
printer_start_page($handle);

printer_draw_text($handle,$var1,980,540);//is printed
printer_draw_text($handle,$var2,1080,540); //is NOT printed

printer_end_page($handle);
printer_delete_font($font);
printer_end_doc($handle);
printer_close($handle);
Is there another way to print to custom paper from php?

Edit/Delete Message


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Write your output to a PDF with autoprint internally embedded?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

What reference did you use to write code that code?
lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

Post by lazaroskyr »

"What reference did you use to write code that code?"

ole I use the manual of php on php.net.I dont get what you mean.Maybe my english is not so good.
Is the code wrong?

Feyd you mean that I send the entire output to a pdf file and from there I do the printing?Php is not able to print to custom(not A4) size?This is what I want and the function printer_set_option does that,but when I send to the printer it is ignored...Is there a default size that php prints anyway?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

ole I use the manual of php on php.net.
Oh right sorry. devNet didn't hyperlink those functions so I didn't think they were in the manual.
I dont get what you mean.Maybe my english is not so good.
No you got it alright, just me being stupid.
Is the code wrong?
I've no idea. I know absolutely nothing about printing in PHP.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

All I know is when I want maximum control over the printing of a document, PDF is the way to go (right now).
lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

Post by lazaroskyr »

So feyd I must redirect the printing to a pdf file and from there I can print everything.Do you know if I can use the same "layout" in the pdf file,as the one that I send to the printer,I mean the gap between the words,some diagrams that I want in a proper position etc.Also I must say that the printing that I need is consisted of very much pdf pages maybe more over than 20.000 pages...Is this possible?
Please allow me also another question.Can I use java to make that printing?Can I call a java program from php?
Thanks in advance.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

o you know if I can use the same "layout" in the pdf file,as the one that I send to the printer,I mean the gap between the words,some diagrams that I want in a proper position etc.
Yes you can. PDF is designed for ensuring consistency of design, if not by default, certainly with a bit of tweaking.
Also I must say that the printing that I need is consisted of very much pdf pages maybe more over than 20.000 pages...Is this possible?
Again this is another thing the PDF format has been designed to do. Although I'm not sure how long it will take PHP to generate such a document. You may need to cache the resultant files.
Please allow me also another question.Can I use java to make that printing?Can I call a java program from php?
Yep

Code: Select all

exec()
Passing data between a PHP script and an external program is best done with files.
lazaroskyr
Forum Newbie
Posts: 11
Joined: Wed Oct 18, 2006 5:21 am

Post by lazaroskyr »

Although I'm not sure how long it will take PHP to generate such a document. You may need to cache the resultant files.
This is what worries me...
Can I call a java program from php?
I've done this before with java calling shell scripts.Maybe is easiest with php...I mean calling an external program.

Anyway ole and feyd thanks for the help.I appreciate it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

When I last used ezpdf, it generated long reports* quite quickly and easily.

* Being ten or more pages.
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

You could instead grab a class from http://www.phpclasses.org for PDF generation, I'm sure you'll find what you are looking for, and what's better, there is a class that is not dependant on any DLL :P Have fun searching.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

That website is like the myspace of the php community.

that means it's crap
Post Reply