Massive PDF's file printing

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

mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Massive PDF's file printing

Post by mikosiko »

Hi,

Apache/PHP under Windows XP

I've been reading/searching a lot (maybe not enough) and I cannot find a method to do this... therefore I need some help if possible.

I have an application (php) that generate several PDF's files.. I can individually open and print them without problem but I've trying to implement something that allows to print all of them massively .. have the name/location of the files therefore I can loop through them and call "something" to print each one... I have tried using backticks, exec, shell_exec like in this simple example :

Code: Select all

<?php

 $file = "MYSQL-explain-diagram.pdf";

 $printcmd = `PDFXCVIEW.exe /print $file`;

 echo "<pre>$printcmd</pre>";

?>


the location for PDFXCVIEW.exe (my pdf viewer) is in the PATH and the file to print do exist... but no luck.. tried also calling a .bat without luck either

the questions are... is even possible to implement this?.. if so... could somebody give me some pointer where/what to look ? or.. how do you guys solve this scenario?

thank you
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Massive PDF's file printing

Post by JakeJ »

If you just want to print them all at once and don't really need to automate it per se, just select all of the files in the folder you want to print, right click, and then click Print. Done.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Massive PDF's file printing

Post by VladSun »

First try using absolute paths for the command itself and the files passed as arguments.
Second, catch the error messages returned:

Code: Select all

 $result = system("/fullpathtoEXE/PDFXCVIEW.exe /print /fullpathtoFile/$file 2>&1");
echo $result;
There are 10 types of people in this world, those who understand binary and those who don't
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

JakeJ wrote:If you just want to print them all at once and don't really need to automate it per se, just select all of the files in the folder you want to print, right click, and then click Print. Done.
Thanks Jake... but I'm talking about an application here. tanks anyway
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

VladSun wrote:First try using absolute paths for the command itself and the files passed as arguments.
Second, catch the error messages returned:

Code: Select all

 $result = system("/fullpathtoEXE/PDFXCVIEW.exe /print /fullpathtoFile/$file 2>&1");
echo $result;
I did that too VladSun... I've tried a lot of things... nothing seems to work...

BTW: My server is a W2003 with Apache/Mysql/PHP
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Massive PDF's file printing

Post by VladSun »

mikosiko wrote:
VladSun wrote:First try using absolute paths for the command itself and the files passed as arguments.
Second, catch the error messages returned:

Code: Select all

 $result = system("/fullpathtoEXE/PDFXCVIEW.exe /print /fullpathtoFile/$file 2>&1");
echo $result;
I did that too VladSun... I've tried a lot of things... nothing seems to work...
What was the output?
mikosiko wrote:BTW: My server is a W2003 with Apache/Mysql/PHP
Well... look at my signature :twisted:
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: Massive PDF's file printing

Post by angelicodin »

After looking over this, perhaps I'm still too new to php, but why not make a loop?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

VladSun wrote: What was the output?
mikosiko wrote:BTW: My server is a W2003 with Apache/Mysql/PHP
Well... look at my signature :twisted:
output... nothing.. zero, zilch, null.... "absolute silence"... I'm perplex

about the signature... :twisted: I know...I know... but no option this time :roll:
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

angelicodin wrote:After looking over this, perhaps I'm still too new to php, but why not make a loop?
seems that you missed the point in my first post... but thanks anyway
buckit
Forum Contributor
Posts: 169
Joined: Fri Jan 01, 2010 10:21 am

Re: Massive PDF's file printing

Post by buckit »

Have you tried the EXEC() command? http://php.net/manual/en/function.exec.php

seems that would be better than system when looping as system will sit and wait for the process to finish before doing anything else. (have never attempted this and have little experience with system or exec. just throwing that out there)
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

Yes buckit... I mentioned that in my first post... thanks for trying to help
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Massive PDF's file printing

Post by Jonah Bron »

What happens when you just run it right from the terminal?
buckit
Forum Contributor
Posts: 169
Joined: Fri Jan 01, 2010 10:21 am

Re: Massive PDF's file printing

Post by buckit »

Maybe try avoiding using a GUI viewer with switches and use a strictly command line printer like verypdf. http://www.verypdf.com/pdfprint/pdf-print-cmd.html

granted its $199. but trying the eval version can let you know if maybe its your current viewer thats causing the issue.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

Jonah Bron wrote:What happens when you just run it right from the terminal?
if you mean the command than I'm using it print the file perfectly (silent No GUI)... same if I use AcroRead32 or NitroPdf or any other pdf viewer
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Massive PDF's file printing

Post by mikosiko »

buckit wrote:Maybe try avoiding using a GUI viewer with switches and use a strictly command line printer like verypdf. http://www.verypdf.com/pdfprint/pdf-print-cmd.html

granted its $199. but trying the eval version can let you know if maybe its your current viewer thats causing the issue.
done that too :)
Post Reply