Hi,
I created a script in PHP to convert mutiple files to PDF using COM. Here it is (defaults to everything in z:\):
$x = new COM('Bullzip.PDFPrinterSettings');
$printername = $x->GetPrinterName;
$runonce = $x->GetSettingsFileName(true);
foreach (glob('z:\*.xls') as $printfile)
{
$x->Init();
$x->SetValue('Output', "$printfile.pdf");
$x->SetValue('ShowSettings', 'never');
$x->SetValue('ShowPDF', 'no');
$x->SetValue('WatermarkText', 'teste');
$x->SetValue('ShowProgress', 'no');
$x->SetValue('ShowProgressFinished', 'no');
$x->SetValue('SuppressErrors', 'yes');
$x->SetValue('ConfirmOverwrite', 'no');
$x->WriteSettings (true);
exec ('z:\printto.exe "' . $printfile . '" "' . $printername . '"');
while (file_exists($runonce))
{
usleep(100000);
}
}
$x = null;
I faced an unusual problem both in Bullzip PDF Printer and PDFcreator and I think is OS related. HTML files always prompt for the "print dialog" no matter you use a script in VBA, C, PHP or whatever, and therefore hang the script. If anyone knows a workaround I would be glad to have it.
If any other file (most usually spreadsheets) cause the host program to ask for saving changes (even if there isn't any), it will also naturally hang the script.
PHP COM script
Moderator: jr
-
- Posts: 1
- Joined: Sun Nov 22, 2009 8:30 pm
Re: PHP COM script
when i try to execute new COM("Bullzip.PDFPrinterSettings") ; php goes in error:
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Bullzip<br/><b>Description:</b> No compatible printers found.' in C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php:4 Stack trace: #0 C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php(4): unknown() #1 {main} thrown in C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php on line 4
Can you help me??
Thank you in advance
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Bullzip<br/><b>Description:</b> No compatible printers found.' in C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php:4 Stack trace: #0 C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php(4): unknown() #1 {main} thrown in C:\Program Files\Apache Group\Apache2\htdocs\bullzip\pdf.php on line 4
Can you help me??
Thank you in advance