Hello
If I try to create a PDF with %26lt;cfdocument%26gt; and want to add a watermark with %26lt;cfpdf%26gt; (on the background, not on the foreground!), there is always a white object (page size) which hides the watermark. Only after deleting the object with Acrobat the watermark gets visible.
I think this is a bug in %26lt;cfdocument%26gt;. I'm not able to produce a PDF without this white rectangle (tried with different HTML-Tags, Plain-Text etc.).
Example:
%26lt;cfdocument format=''pdf'' filename=''test.pdf''%26gt;test%26lt;/cfdocument%26gt;
%26lt;cfpdf action=''addwatermark'' image=''test.jpg'' foreground=''no'' source=''test.pdf''%26gt;
System:
CF 8.0.1 (Update April 08)
Any ideas/similar experiences?
cfdocument produces white rectangleIs this happening with a licensed version of CF or the developer version??I am wondering if the standard watermark on the developer version is interfering with yours.
cfdocument produces white rectangleThank you for your input. I work with a licensed ColdFusion Standard version.
The mentioned object is imho not a watermark. Otherwise I should be able to delete it with %26lt;cfpdf action=''removeWatermark''%26gt; (doesn't work).
It sounds like a bug. The same code worked with a regular acrobat file. Just not with a pdf created by cfdocument.
Unfortunately, I cannot think of another workaround.?Tests using ddx?%26lt;Background%26gt;?and using iText directly to apply the watermark (ie PdfStamper / getUnderContent()) produced the same result for me:?ie watermark is not visible.?I would submit a bug report.
I found a post on houseoffusion.com that suggested a work around using css.?It is a bit of hack, but if you create an image of the right size (letter, landscape) it should do the trick:
ie
%26lt;style%26gt;
body { background-image: url(yourWatermarkLetterSize.gif);
%26lt;/style%26gt;
http://www.mail-archive.com/cf-talk@houseoffusion.com/msg337518.html
Thank you for the valuable inputs.
The only way for me was to write it with itext, so i was also able to really embed the font (the embedding with cfdocument doesn't work, if you don't have the font on your local system).
If somebody is looking for a similar solution, I post here the code for putting text on a existing pdf with a watermark (in the background!):
// Path for the PDF-Documents (output.pdf must exist there)
%26lt;cfset variables.pfad = ''[Absolute path]''%26gt;
%26lt;cfscript%26gt;
fileIO=createObject(''java'',''java.io.FileOutputStream'');
fileIO.init(#variables.pfad# %26amp; ''output.pdf'');
reader = createObject(''java'',''com.lowagie.text.pdf.PdfReader'');
reader.init(#variables.pfad# %26amp; ''original.pdf'');
basefont = createObject(''java'',''com.lowagie.text.pdf.BaseFont'');
//Sample with Font ''Univers'', Installed on the CF-Server
bfUnivers = BaseFont.createFont(''c:\windows\fonts\unvr55w.ttf'', BaseFont.CP1252, BaseFont.EMBEDDED);
pdfStamper = createObject(''java'',''com.lowagie.text.pdf.PdfStamper'').init(reader, fileIO);
// Place Text on Page 1
document = pdfStamper.getOverContent(1);
document.beginText();
document.setFontAndSize(bfUnivers, 18);
document.setTextMatrix(90, 300);
document.showText(''Test'');
document.endText();
pdfStamper.close();
%26lt;/cfscript%26gt;
pfurrer wrote:
putting text on a existing pdf with a watermark (in the background!):You understood everything correctly: I needed the image in the background, not the text. The watermark-image is now in the original pdf, with getOverContent I put the text in front of the image
Ah, okay.?For anyone else, as of 8.0.1, you can use cfpdf for a foreground text watermark.
http://www.coldfusionjedi.com/index.cfm/2008/4/4/ColdFusion-801--Easier-to-add-P DF-Watermarks
No comments:
Post a Comment