I'm reviewing a spec. that calls for all files uploaded via a file field to be automatically converted to PDF format. I have two questions:

  1. Is this wise? Files would be uploaded by anonymous customers. Allowed file extensions (.doc, .xls, .png, .jpg, etc) would be provided as per normal file field use.

(Edited to clarify my main concern is security)

  1. Are there any conversion tools you would recommend? Paid or free is fine. Remote service is fine, local server-based is preferable. I can't find anything in the Drupal-verse, but have uncovered tools such as unoconv and JODConverter that look promising.

2 Answers 2


Personally, I would store the file as it was uploaded, and then render it as a PDF for users when they download it. Your spec may say PDF now, but you want to have the flexibility should things change in the future.

Is this a good idea? That is a tough question, and really depends on the exact scenario. Personally, I would push back on this requirement. Format conversion can tax system resources, and I don't think you can really constrain the .doc and .xls formats enough, like you can with images, to be something reasonable.

Tools? The Printer, email and PDF versions module has a list of of the PHP-based PDF modules:

I am unaware if any of these will support .doc or .xls formats. I have used Ghostscript to convert images to PDF, and I am pretty sure it has some support for .doc. I am unaware of any Drupal-ready solution for this, though.

As for security implications, the scenario "makes my spidey sense tingle", but I can't point to anything in particular. I don't think you would have any problems with any of the malicious payloads in .doc and .xls files that normally affect Windows machines. However, if you go with a solution like GS, you will have to use a popen() or something similar, so you run the risk of an exploit there.

  • Thanks for the feedback MPD. My main concern re: this being a good idea is around security. These are anonymously uploaded files. Performance is less important.
    – mesch
    Dec 31, 2012 at 17:55

See if https://github.com/delphian/drupal-convert-file/wiki fits your needs. It will make a backup of the original file, and uses remote providers (currently google drive) to do the actual file conversion. The google drive provider will convert .doc .xls and .txt to .pdf.

  • Have you tried the github project yourself? Why is it not a drupal.org project, is it stable enough>
    – Yuri
    May 10, 2015 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.