Here's my current attempt to convert JPG to PDF using ColdFusion. I used cfdocument because it seemed easy to use:
<cfdocument format="PDF" name="jpgtopdf" mimetype="image/jpeg" srcfile="#myfile#" pageheight="11" pagewidth="8.5">
</cfdocument>
Unfortunately this reduces the resolution to 72 DPI, destroying the details in the JPG. I would like to preserve the original JPG resolution. What is the best way to convert JPG to PDF?
--
EDIT: When I put <img>
inside <cfdocument>
it just produces a blank document. I believe this happens because, for security, #myfile#
is outside the webroot. Fortunately, this led me to this answer: stackoverflow.com/questions/4813587/dynamic-pdf-cfdocument-cfcontent-image-email-attachement which indeed allows the conversion to be done with higher resolution. Here is my new code which seems to produce 300 DPI:
<cfdocument format="PDF" name="jpgtopdf" pageheight="11" pagewidth="8.5">
<cfimage action="writetobrowser" source="#myfile#">
</cfdocument>
Try this:
On CF11 it gives nice result.