This module is an addition to the print module. I made a patch previously but then the owner of the print module implemented some hooks for different PDF libraries.
See: http://drupal.org/node/826820
This module implements support for Prince XML library.
This is for Drupal 7
Sandbox:http://drupal.org/sandbox/ayalon/1733058
Install instructions:
1. Download princexml from
http://www.princexml.com/download/
2. Install the prince executable on your server.
Note: If you are using windows, don't install prince in a folder with spaces, it
won't work, use "C:\Prince\" instead. If you have safe_mode enabled, place the
binary in the safe_mode binary folder.
3. Download php wrapper class from
http://www.princexml.com/download/wrappers/
4. Copy prince.php to sites/all/libraries/prince/prince.php
5. Set the path to the binary in the PDF settings
under admin/config/user-interface/print/pdf/princexml
6. All settings to the pdf output can be made via CSS Style sheet. See f.ex.
http://www.princexml.com/doc/7.0/page-size/
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | prince_xml_pdf_library-requirements_screen_fix.patch | 1.89 KB | rupertj |
| #8 | tonga_2013052408:52:40.png | 124.13 KB | siliconmeadow |
| prince.jpg | 8.9 KB | ayalon |
Comments
Comment #1
dman commentedProject page
As per the issue you linked to in the 'print' queue, this is a non-free library. You should clearly announce on the project page that this solution puts a logo on every page until you pay for it.
You should also state that this requires root-like powers on your server to install the binary (as do some of the other solutions AFAIK, but note this dependency clearly on the project page.
Visual code check:
.install : looks fine
.pages.inc : looks god. small clean code, fine comments.
.admin.inc : ditto. Correct API etc.
.module : small and well structured. Would like a comment on print_pdf_princexml_print_pdf_available_libs_alter() as that currently looks like black magic out of context. I'm sure it makes sense though.
Automated code check
There is a small amount of noise from the PAReview check, but certainly nothing I'd worry about.
Functional testing
You add this utility in a new section of modules admin called 'AYALON'. While cute, it's not helpful when it should probably be with the other 'PRINTER, EMAIL AND PDF VERSIONS' modules.
It wasn't too hard to find my way to the settings at /admin/config/user-interface/print/pdf/princexml , though a link to the rest of the install instructions there (link to the download site at least) would be handy in the UI, not just the README.
You could (potentially) add a .make file to assist the download of the wrapper class into /libraries, but given that we need to do a server-side install,
Security issue
The path to binary setting on admin/config/user-interface/print/pdf/princexml is not validated and in fact allows any binary server-side code to be run.
Looking at the way this is used, and prince.php, this input is NOT CHECKED OR SANITIZED in any way and basically means and command can be run there.
This is a huge security thing. It's not the fault of the prince.php library, it's just that the print_pdf_prince_binary value needs protection. Somehow.
writing secure code
System warning
After installing the binary and giving the path to it, my system report at admin/reports/status announced
(I installed print.module 7.x-2.x - not sure if that's an API change that it made)
But otherwise print.module configs seemed to recognize it.
After all that, I can confirm that the module actually works and produces PDFs using this library. I won't go playing with the layouts, but I'll believe that it provides the additional control you were looking for.
Summary
Please take some steps to mitigate the potential security issue around allowing the webserver to execute ANY commandline command (this is a blocker), and sort out the system warning in the site status report.
The rest of the code and architecture is fine by me though.
Comment #2
ayalon commentedHi
Thanks for your review. I took care of all points mentiond and updated the module:
1. There is now a security check on the binary path and shell arguments are escaped.
2. I've implemented hook_requirements() and I check the execute permission of the binary
3. The errors on the requirement page are fixed
4. I have update the the project page according to your proposals
5. I changed the group of the module to "Printer, email and PDF versions"
Comment #3
iwhitcomb commentedPlease check the release naming conventions as you are currently using the master branch. http://drupal.org/node/1015226
You also have some things to fix per the automated code review at http://ventral.org/pareview/httpgitdrupalorgsandboxayalon1733058git
Comment #4
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
Comment #5
ayalon commentedPlease review my module, it's still used and under development.
Comment #6
PA robot commentedLink to the project page and git clone command are missing in the issue summary, please add them.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #7
siliconmeadow commentedHi,
The module is working for me - straight after installing.
As an end-user, it doesn't seem apparent how or where to set the PDF settings a you state:
Could you provide a bit more documentation on how this works? The PrinceXML documentation seems ok, but the disconnect between your documentation on the Drupal side and what makes PrinceXML work is too great. Where does the stylesheet go? Would it make sense for you to provide a default stylesheet with some sane settings?
All the best,
Richard
Comment #8
siliconmeadow commentedWith this module installed, when I go to

/admin/reports/status, I see this:Comment #9
rupertj commentedHere's a patch to fix the requirements screen issues. This had 2 problems:
1) The function to get the prince binary version was just a stub.
2) the hook_requirements implementation was using the same keys as print_pdf.
Also, the .install file is wrongly named (print_pdf_prince.install, not print_pdf_princexml.install). I spotted that after I made the patch though, so that's not included.
I should add that we're using this module in production and it works well :)
Comment #10
siliconmeadow commentedI have applied rupertj's patch on a my local dev site and it all works fine, so you could consider that patch itself as RTBC'd.
Now would be a good time for you to at least deal with adding that patch and demonstrating the proactive way you will be addressing your issue queue!
Comment #11
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application.
I'm a robot and this is an automated message from Project Applications Scraper.