开发者

iText flattening issue with watermark text

开发者 https://www.devze.com 2023-03-16 03:29 出处:网络
I am using iTextSharp to add watermarks to existing documents that are in PDF format. I read them in, create a PdfTemplate object, add the watermark text, color, transparency, etc... to this PdfTempla

I am using iTextSharp to add watermarks to existing documents that are in PDF format. I read them in, create a PdfTemplate object, add the watermark text, color, transparency, etc... to this PdfTemplate, then add the template to a PdfContentByte that I get using PdfWriter.DirectContent.

This solution has been working for a while for all documents that I throw at it, but for some reason a few particular PDFs have been printing with an opaque rectangle around the watermark text.

I have tried a number of things already, including setting the PdfGState's OverPrintMode to 1, opening the generated file after it is created and then using PdfStamper's setFormFlattening and setFreeTextFlattening before saving a new copy... Nothing has worked so far.

The issue is that I don't care about flattening form fields or b开发者_开发技巧uttons, I just want to flatten all the layers of the document after I have generated the entire thing. Is this even possible with the iText API?


Alright, coming back to close this one out since I solved it a long time ago:

The issue was that the pdfs having the issue were very old (v1.3 of the PDF standard) and did not support the transparency that was a part of the watermark element.

I got around this by printing the old PDF via a virtual printer to a temporary file, then continuing to process that file, which was now a newer version of the PDF standard.

0

精彩评论

暂无评论...
验证码 换一张
取 消