Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfdocument produces white rectangle

Community Beginner ,
Jun 24, 2009 Jun 24, 2009

Hello

If I try to create a PDF with <cfdocument> and want to add a watermark with <cfpdf> (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 <cfdocument>. I'm not able to produce a PDF without this white rectangle (tried with different HTML-Tags, Plain-Text etc.).

Example:

<cfdocument format="pdf" filename="test.pdf">test</cfdocument>

<cfpdf action="addwatermark" image="test.jpg" foreground="no" source="test.pdf">

System:

CF 8.0.1 (Update April 08)

Any ideas/similar experiences?

TOPICS
Advanced techniques
3.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 24, 2009 Jun 24, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 25, 2009 Jun 25, 2009

Thank 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 <cfpdf action="removeWatermark"> (doesn't work).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 25, 2009 Jun 25, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 27, 2009 Jun 27, 2009

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

<style>

body { background-image: url(yourWatermarkLetterSize.gif);

</style>

http://www.mail-archive.com/cf-talk@houseoffusion.com/msg337518.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 20, 2009 Aug 20, 2009

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)

<cfset variables.pfad = "[Absolute path]">

<cfscript>
fileIO=createObject("java","java.io.FileOutputStream");
fileIO.init(#variables.pfad# & "output.pdf");
reader = createObject("java","com.lowagie.text.pdf.PdfReader");
reader.init(#variables.pfad# & "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();

</cfscript>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 20, 2009 Aug 20, 2009

pfurrer wrote:

putting text on a existing pdf with a watermark (in the background!):

Oh. For some reason I thought you were using an image, not text 😕 But be aware getOverContent is the page foreground not background:

        getOverContent(...) - Gets a PdfContentByte to write over the page of the original document.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 21, 2009 Aug 21, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 21, 2009 Aug 21, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources