3

我能得到的最接近的是使用这段代码

<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> 

这让我非常接近我的 TIF 图像的精确副本,但由于某种原因,图像在宽度上减少了 5 个像素,我不知道为什么。

更多细节:ad1.tif 图像为 1425x1125,生成的最终 pdf 文档为 1725x2625。如您所见,我在 cfdocument 上使用 5.75 x 8.75 英寸。这转换为 300DPI 的 PDF 文档。当我在 Photoshop 中加载 PDF 文档时,它确实声明该文档为 300DPI。

您可能会注意到 ImageNew 使用 1725x2625 而 cfimage 使用 1740x2625。如果我将 cfimage 尺寸与 imagenew 相匹配(这很有意义),那么您最终会在顶部、右侧和底部都有这个白色边框。图像在宽度上仍然偏离了大约 5 个像素。所以我不得不把它弄大一点来摆脱那个白色的边框。如果我能弄清楚为什么该图像偏离了 5 个像素。

4

1 回答 1

0

很明显,您的原始问题已得到解答,但对于图像分辨率问题,您可以尝试添加scale="100"到您的cfdocument标签中。这可能会阻止它缩小图像(这与降低分辨率相同)。我不确定它是否会起作用,因为我还没有尝试过。

作为旁注,我不明白为什么人们一直在评论中而不是在答案中回答问题。

于 2014-04-03T01:06:42.713 回答