1

I cannot get PrinceXML to work on my Windows Server. I am using the PHP wrapper class, although am unable to find any helpful documentation for it!

The information supplied in the README file (within the download) here does not explain what is being done, nor does it offer any sample code.

This is what I have put together so far (very basic), but nothing is being printed, and no errors are being displayed.

I know that I have not included header('PDF HEADERS HERE'), this is simply because I am trying to see what the PHP errors are before I print the PDF.

$prince = new Prince('C:\Program Files (x86)\Prince\Engine\bin\prince.exe');

try{
    $prince->convert_string_to_file('<span>Hello World</span>','test.pdf');
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

I have played around a lot with the above code but absolutely nothing I have tried is work. Even if I change the path to the prince.exe, no error is returned! Why??

My questions are:

  1. How can I print the errors that are encountered?
  2. Are there any sites with good documentation for this class?
Anderson Pimentel
  • 5,086
  • 2
  • 32
  • 54
Ben Carey
  • 16,540
  • 19
  • 87
  • 169
  • Just a question - did You tried or heard of `mPDF` library? I used it on some projects with success - the outputted PDF looked the same as the original HTML. It allows You to also include CSS stylesheets or other resources (images, etc). It is quite easy to use and well documented. – shadyyx Jan 17 '13 at 11:33
  • @shadyyx I'm afraid it is too slow, and I am needing a library that can convert dynamically generated pages to PDF. I think I will need to use `wkhtmltopdf`, although I am not sure if it works on Windows... – Ben Carey Jan 17 '13 at 12:03
  • I used it on dynamically generated HTML :-) And didn't find it slow... – shadyyx Jan 17 '13 at 12:06
  • @shadyyx I apologise, I have got confused with what I was trying to do. Because I am testing, I wanted to convert one of my existing PHP pages to PDF, when in fact what I ***will*** be doing, is just generating a PDF from very basic HTML! In that case, this should be fine, the only issue is the speed. :-) Thank you – Ben Carey Jan 17 '13 at 12:13

2 Answers2

0

Call $prince->setLog(path_to_log_file) and make sure that the specified log file path is writable from your PHP code.

andr
  • 15,970
  • 10
  • 45
  • 59
Michael Day
  • 1,007
  • 8
  • 13
0

just give full path here

$prince->convert_string_to_file('Hello World','D:\testfolder\test.pdf');

thats all you can get your test.pdf in d drive test folder

Ishak Ali
  • 340
  • 4
  • 10