本文介绍了CFPDF添加水印任何级别的透明度都变得不透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将pdf水印添加到另一个pdf时,水印PDF中的任何半透明性都变得完全不透明.我对此有什么办法吗?还是CFPDF的局限性?

When I watermark a pdf onto another pdf any semi-transparency in the watermark PDF is made completely opaque. Is there anything I can do about this or is this a limitation of CFPDF?

服务器是具有最新修补程序的CF9.

Server is CF9 with latest hotfixes.

有趣的是,当chrome渲染最终产品时,透明度会保留,但是当Acrobat Pro渲染时,它是不透明的.我可以将最终产品打印到AdobePDF上,并且它是完全透明的,但是我无法通过我们的打印店发送一致的页面尺寸,这是一个严重的问题.

Fun bit, when chrome renders the final product the transparency is preserved, but when Acrobat Pro renders it it's opaque. I can print the final product to AdobePDF and it's accurately transparent, but I don't get a consistent page size to send through our print shop which is a showstopper issue.

每个请求添加的代码:

<cfpdf  action="addwatermark"
    source="#BackgroundPDF#"
    copyfrom="#ForegroundPDF#"
    destination="#DestinationPDF#"
    foreground="yes"
    opacity="10"
    overwrite="yes"
    position="#XYPositioning#"
    rotation="#RotationIfRequired#"
    showonprint="yes"
  >

我在进行过程中发现的其他详细信息:如果使用Acrobat Pro,则可以进行印刷生产,并输出预览,并将显示"选项更改为非DeviceCMYK",然后我又恢复了透明度,但这只是一种预览,我该如何从PDF中删除该色彩空间?

Additional detail I've discovered as I go along: if I get on Acrobat pro, I can go to print production, and output preview and change the "show" option to "Not DeviceCMYK" and I get my transparency back, but this is just some kind of preview, how do I actually remove that colorspace from the PDF?

推荐答案

感谢@mkl提供的帮助,我们能够弄清楚如何对pdf二进制文件进行修补.因此,我只需要能够在CF中进行操作即可.由于将文件读取为文本文件会导致由于字符编码而引起的问题,因此我能够做到这一点.

Thanks to the help provided by @mkl Here we were able to figure out how to monkey patch the pdf binary. So then I just need to be able to do so in CF. Since reading the file in as a text file causes problems due to character encoding I was able to do this.

  1. 标识要在二进制文件中更改的文本.这就是@mkl帮助了我.问题文字为"/K true",表示PDF使用剔除组,我相信这对PDF专家是有意义的但对我来说完全是希腊语.

  1. Identify the text to change in the binary. This is what @mklhelped my with. The problem text is "/K true" which is telling thePDF to use knockout groups which I'm sure makes sense to PDF expertsbut is total Greek to me.

将pdf作为二进制< cffile action ="readbinary" file =#inputPath#" variable ="input">

将二进制字节数组编码为十六进制< cfset temp = BinaryEncode(input,"Hex")>

Encode the binary bytearray to Hex <cfset temp=BinaryEncode(input,"Hex")>

删除我想删除的现在为十六进制的字符串< cfset temp2 = ReplaceNoCase(temp,"2F4B2074727565",","All")<!--2F4B2074727565是HEX/K true --->

Remove the, now hex, string I want removed <cfset temp2 = ReplaceNoCase(temp,"2F4B2074727565","","All")><!--- 2F4B2074727565 is HEX for /K true --->

将十六进制解码回字节数组< cfset output = BinaryDecode(temp2,"Hex")>

Decode the Hex back into a bytearray <cfset output = BinaryDecode(temp2,"Hex")>

将输出文件写入文件系统< cffile action ="write" file =#outputPath#" output =#output#" nameconflict ="overwrite">

Write the output file to the file system <cffile action="write" file="#outputPath#" output="#output#" nameconflict="overwrite">

现在,您的PDF看起来像预期的那样.问题是它有问题.如果我打开它,什么也不做,然后关闭它,提示我保存.如果保存,则不再有问题.我认为CFPDF合并操作基本上可以做到这一点,而无需用户做任何事情,因此我添加了最后一步.

Now you have a PDF that looks like expected. The problem is that there is something wrong with it. If I open it, do nothing, and close it I'm prompted to save. If I save it, I no longer have an issue. I figured that a CFPDF merge operation would do basically this without requiring a user to do something so I added this final step.

  1. 使用合并命令< cfpdf action ="merge" source =#outputPath#" destination ="outputPath2" pages ="1" overwrite ="yes">

这篇关于CFPDF添加水印任何级别的透明度都变得不透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!