Page 1 of 1

PHP printing problem

Posted: Wed Oct 18, 2006 8:49 am
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]

Posted: Wed Oct 18, 2006 11:58 am
by feyd
Write your output to a PDF with autoprint internally embedded?

Posted: Wed Oct 18, 2006 12:57 pm
by Ollie Saunders
What reference did you use to write code that code?

Posted: Wed Oct 18, 2006 3:06 pm
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?

Posted: Wed Oct 18, 2006 4:59 pm
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.

Posted: Wed Oct 18, 2006 5:11 pm
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).

Posted: Thu Oct 19, 2006 12:34 am
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.

Posted: Thu Oct 19, 2006 6:18 am
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.

Posted: Thu Oct 19, 2006 7:15 am
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.

Posted: Thu Oct 19, 2006 7:18 am
by feyd
When I last used ezpdf, it generated long reports* quite quickly and easily.

* Being ten or more pages.

Posted: Thu Oct 19, 2006 7:27 am
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.

Posted: Thu Oct 19, 2006 7:29 am
by Ollie Saunders
That website is like the myspace of the php community.

that means it's crap