3

The closest I have been able to get is using this code

<cfset Background = ImageNew("",1725,2625)>
<cfimage source="#APPLICATION.config.serverpath#/ad1.tif" name="ad1">
<cfset height1   = ImageGetHeight(ad1)> 
<cfset width1    = ImageGetWidth(ad1)>
<cfset resImage1 = ImageCopy(ad1,0,0, width1, height1)> 
<cfset ImagePaste(Background,resImage1,150,150)>

<cfdocument format="pdf" pagetype="custom" pagewidth="5.75" pageheight="8.75" fontembed="no" name="temp" margintop="0" marginbottom="0" marginleft="0" marginright="0">
<div style="position:absolute; top:0; left:0; right:0; bottom:0; z-index:0;width:100%;height:100%;">
<cfimage action="writeToBrowser" source="#Background#" style="width:1740px; height: 2650px;">
</cfdocument> 

This gets me very close to the exact duplicate of my TIF image, but for some reason the image is reduced by like 5 pixels on the width, and I cannot figure out why.

A bit more details: The ad1.tif image is 1425x1125, the final pdf document that gets produced is 1725x2625. As you can see I use 5.75 x 8.75 inches on the cfdocument. This translates in the PDF document being 300DPI. When I load up the PDF document in photoshop it does state the document is in 300DPI.

You might notice that the ImageNew uses 1725x2625 and the cfimage uses 1740x2625. If I matched the cfimage dimensions to the imagenew (which makes perfect sense), then you end up with having this white border on the top, right, and bottom. The image is still off by like 5 pixels on the width. So I am forced to make it a bit bigger to get rid of that white border. If I can just figure out why that image is 5 pixels off.

user1322114
  • 317
  • 2
  • 10
  • Does it make any difference if you code the conversion of the image within the `cfdocument` tag attributes instead of within the tags? Something like this `` as [documented here](http://forums.adobe.com/thread/71997). – Miguel-F Nov 14 '13 at 19:21
  • Ok I made this change It does perfectly put the page together with no weird pixels being off... BUT... the whole PDF is in low res. – user1322114 Nov 17 '13 at 08:13
  • It does perfectly put the page together with no pixels being off... The temp.tif is in hi-res. When I load the PDF into photoshop, it shows 300 DPI, right dimensions, etc... but the actual image is very low res. It looks like 72DPI. – user1322114 Nov 17 '13 at 08:23
  • Hmmm? What is the DPI of the original image? – Miguel-F Nov 17 '13 at 16:35
  • The TIF file is 300 DPI, nice and sharp. – user1322114 Nov 17 '13 at 17:29
  • why make it complicated just paste the image into word and save it as a PDF not sure about quality but it does look almost exact – CMS_95 Nov 18 '13 at 03:14
  • I wish! This is used within an automated system where it creates a 70 page PDF. All the images are dynamic. – user1322114 Nov 18 '13 at 07:10
  • 1
    If you're running CF on Linux, and have Imagemagick installed, it's as simple as executing `convert foo.tif foo.pdf` - Keep your web server free for processing web requests and leave image processing for your background workers – Mike Causer Dec 06 '13 at 15:18

1 Answers1

0

Well obviously your original question has been answered, but for the image resolution issue, you might try adding scale="100" to your cfdocument tag. That might prevent it scaling the image down (which is the same thing as lowering resolution). I'm not sure it will work, since I haven't tried it.

As a side note, I don't understand why people keep answering questions in the comments instead of in the answers.

Samuel Dealey
  • 263
  • 1
  • 7