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

Why does AddWatermark make file so big?

New Here ,
Apr 28, 2010 Apr 28, 2010

Copy link to clipboard

Copied

I have created a 600 x 253 72 dpi gif file.  It is only 36kb in size.  When I take a 7 page 220kb PDF file and do a cfpdf action="addwatermark" to the file, it grows from 220kb to a whopping 1.3 MB!

Strangely enough, if I open the same file in Adobe Acrobat Professional and manually add the exact same gif file as a watermark to the exact same PDF file, the result file actually got SMALLER!?!?!

You don't believe me?  Try it yourself.

Image file: https://www.calcerts.com/images/logo_main_watermark_color.gif

Original PDF: https://www.calcerts.com/BB4031.pdf

PDF File after doing a simple addwatermark: https://www.calcerts.com/BB4031_WTF.pdf

PDF File if I add the image as a watermark in Adobe Acrobat Professional 8: https://www.calcerts.com/BB4031_AdobeWatermarked.pdf

The code I used was this:

<cfpdf action="addwatermark"
  source="d:\BB4031.pdf"
  destination="d:\BB4031_WTF.pdf"
  image="D:\images\logo_main_watermark_color.gif"
  opacity = 2
  foreground = "yes"
  rotation = 0
  showonprint = "yes"
  overwrite="yes"
  position = "0,250"
  >

TOPICS
Advanced techniques

Views

3.4K

Translate

Translate

Report

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 ,
Apr 28, 2010 Apr 28, 2010

Copy link to clipboard

Copied

My guess would be it is how the watermark image is added internally. From the size increase, it seems like the image bytes are added to the pdf multiple times. ie Once per page. As opposed to adding them once, and then reusing some sort of reference.  But that is just a guess. You might also submit a bug report on this behavior.

If you have createObject("java") access, you could always use iText to add the watermark. It is not as simple as cfpdf. But done correctly, it does not increase the file size so drastically.  If you are looking for an iText example, see the entry below. I wrote it for another problem. But you could easily adapt it.

http://cfsearching.blogspot.com/2009/06/cfpdf-issues-when-using-transparent.html

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

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
New Here ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

Awesome.  It does not answer the why problem, but it did offer an alternative thing for me to do.  The iText worked great.  I think I am going to be doing some iText learning, because the file is significantly smaller.

As you said, it's not as easy, but it works nicely.

Also, FYI - you need to fix your sample code. On line 30, it says:

ii = i + 1;

I think you need only one i.  The while loop goes to infinity. 

Votes

Translate

Translate

Report

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 ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

Awesome.  It does not answer the why problem, but it did

offer an alternative thing for me to do. 

Yes, I do not know the technical implementation. But it is a pretty good guess the image bytes are being added multiple times. Do not forget to submit a bug on it.

Also, FYI - you need to fix your sample code. On line 30,

it says:

 

ii = i + 1;

 

I think you need only one i.  The while loop goes to

infinity. 

Thanks. I will check into that. Most likely blogger is messing up the code examples. It does something funky to the formatted code whenever certain elements are present like BR's. (Thank you very much blogger ...;)

Votes

Translate

Translate

Report

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
New Here ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

Thanks for your information on the Forums page.

Is there a place where I can get basic documentation for iText and ColdFusion?

The example you gave me will work for adding the watermark, now all I need to do is be able to add a footer to every page and to add some text to a specific page via an x,y coordinate.  Once I have those two things done, my iText and PDF days of trouble are gone.

I tried sending you a private message (since this is really not a Forum topic), but when I click on your profile, the To: line has a dash (-) instead of your handle.  So It would not send it to you.

Thanks.

Votes

Translate

Translate

Report

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 ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

Is there a place where I can get basic documentation for

iText and ColdFusion?

There are some scattered articles on combining iText and CF. But mostly the documentation is all java. Because most of the code is the same. You just call it with createObject(..). The iText site itself has tons of examples. I have translated some of them into CF on my blog. Check the iText category.

There is one on adding headers/footers with page events here:

http://cfsearching.blogspot.com/2009/11/better-itext-pdfpageeventhandler-with.html

BTW: It looks like part of variable code problem is due to the js code formatter. So in future, just use the "plain view" option (top left) and copy the code from there.

Votes

Translate

Translate

Report

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
New Here ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

I can't thank you enough for all the help you are giving me, but I just hit a brick wall.  I am not really a "coder" by any stretch of the imagination.  I am more of a cut 'n paste sort of guy that tweaks the code a bit to make it work.  So I read your article (light hearted and easy to read) but very difficult for me to understand exactly what to do.  So I will tell you what I did and you can tell me what I did wrong.

1) downloaded the CFCDyamicProxy from the website link you provided.  I created a mapping in CFAdministrator to the folder.  I ran a couple of the "Sample" files and got no errors, so I assume it installed properly.

2) Downloaded iText JAVA-PDF library 5.02 and put it in the same folder so I could use the mapping.

3) I then copied and pasted your example (and changed the reference of the iText to the 5.02 version instead of your 2.17).

4) Ran the CFM file and got this error:

Could not find the ColdFusion Component or Interface PdfPageEventHandler.

so obviously I am missing something, but don't know what.

btw, should I be e-mailing you on the side or should we keep this on the Forum?  also, if you can't be bothered with this, I totally understand just let me know.

Here is the CFM file I created:


<cffunction name="onEndPage" access="public" returntype="void" output="true"
    hint="Called when a page is finished, just before being written to the document.">
<cfargument name="writer" type="any" required="true" hint="Writer for the target pdf. Instance of com.lowagie.text.pdf.PdfWriter" />
<cfargument name="document" type="any" required="true" hint="Document for target pdf. Instance of com.lowagie.text.Document" />
<cfset var Local = {} />

<cfscript>
if (len(variables.instance.footerText))
{
     Local.cb = arguments.writer.getDirectContent();
     Local.cb.saveState();

     Local.cb.beginText();
     Local.cb.setColorFill( variables.instance.textColor );
     Local.cb.setFontAndSize( variables.instance.font, javacast("float", variables.instance.fontSize) );
     Local.cb.setTextMatrix( arguments.document.left(), arguments.document.bottom() - 10);
     Local.text = variables.instance.footerText &" page ["& arguments.writer.getPageNumber() &"]";
     Local.cb.showText( Local.text );
     Local.cb.endText();

     Local.cb.restoreState();
}
</cfscript>

</cffunction>

<cfscript>
//add the javaloader dynamic proxy library (and the iText jar) to the javaloader
libpaths = [];
arrayAppend(libpaths, expandPath("/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar"));
arrayAppend(libpaths, expandPath("/javaLoader/itext/iText-5.0.2.jar") );

//we HAVE to load the ColdFusion class path to use the dynamic proxy, as it uses ColdFusion's classes
loader = createObject("component", "javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);
</cfscript>

<cfscript>
//intialize the page event handler component
eventHandler = createObject("component", "PdfPageEventHandler").init( font=textFont, fontSize=10, textColor=textColor);
//add a custom footer
eventHandler.setFooterText( "www.clueless.corp * 85 anywhere blvd * lost city" );

//we can pass in an array of strings which name all the interfaces we want out dynamic proxy to implement
interfaces = ["com.lowagie.text.pdf.PdfPageEvent"];

//get a reference to the dynamic proxy class
CFCDynamicProxy = loader.create("com.compoundtheory.coldfusion.cfc.CFCDynamicProxy");

// create a proxy that we will pass to the iText writer
eventHandlerProxy = CFCDynamicProxy.createInstance(eventHandler, interfaces);
</cfscript>
<CFABORT>


<cfscript>
fullPathToOutputFile =  "d:\20833P2_After.pdf";

  document = loader.create("com.lowagie.text.Document").init();
  outStream = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile);
  writer = loader.create("com.lowagie.text.pdf.PdfWriter").getInstance(document, outStream);

  // ** register the PROXY as the page event handler **
  writer.setPageEvent( eventHandlerProxy );
     
  document.open();
  Paragraph = loader.create("com.lowagie.text.Paragraph");
  document.add( Paragraph.init("Paragraph Text....") );
  document.newPage(); 
  document.add( Paragraph.init("Paragraph Text....") );
  document.newPage();
  document.close();
  outStream.close();

  WriteOutput("Done!");
</cfscript>

Votes

Translate

Translate

Report

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 ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

also, if you can't be bothered

with this, I totally understand just let me know.

No, I do not mind. But the first thing I would say is the example was not tested with the 5.x version. A lot of things have changed. Including the package names ... and also license. (Be sure to look at it). So it will not work with v5.x.

My schedule is packed today and most of tomorrow. But I would be happy to take a look at this tomorrow afternoon/evening.

-Leigh

Votes

Translate

Translate

Report

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 ,
Apr 29, 2010 Apr 29, 2010

Copy link to clipboard

Copied

so I assume it installed properly.

Yes, if you can run the JavaLoader examples it is installed properly

2) Downloaded iText JAVA-PDF library 5.02 and put it in the

same folder so I could use the mapping.

Download 2.1.7 instead. (The code will not work with 5.x "as is"). So your jar path would be: /javaLoader/itext/iText-2.1.7.jar

4) Ran the CFM file and got this error:

The example requires two files: a .CFM script to run the code and a .CFC containing the cffunctions (like onPageEnd). If you follow the example, the component must be named: PdfPageEventHandler.cfc.  You can download a working example using the box.net widget on the right menu of the blog. Extract the .zip and copy the entire "betterPdfPageEventHandler" directory anywhere in your webroot.

         Example:

         C:\ColdFusion8\wwwroot\betterPdfPageEventHandler

Then open up index.cfm, fix the jar paths, and run the script. It  creates a sample pdf (with footers) in the same directory.

BTW: If you are using the javaLoader, be sure to see this article on avoiding memory leaks:

http://www.compoundtheory.com/?action=displayPost&ID=212

HTH

-Leigh

Votes

Translate

Translate

Report

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
New Here ,
Apr 30, 2010 Apr 30, 2010

Copy link to clipboard

Copied

SWEEEET!!!!

It worked!  Up until I started messing with the example.  lol

So I have an example from you that takes an existing PDF file and adds a watermark - works perfectly.

I have an example of creating a NEW PDF file and adding footer info to it.  I was able to change the text of the footer (and the font/color to match my needs), but a couple of noob issues.

1) It wants to insert page numbers.  I am guessing it is a default, because I can't find anything in the sample code adding the page numbers.  I don't want the page numbers, how do I get rid of those?

2) Your example is CREATING a PDF file, and adding the footer to it.  I tried to read an existing PDF and add the footer and I kept breaking it.  I can't get the input and the output to jive.

It will likely take you less time to write it than to explain it, and again, if you don't want to, no worries:

I need two sample cfm files:

1) Add a footer:

Read a file: base.pdf

Add a footer "My Footer on every page" to every page of the file (no page numbers)

Output the file to: base_out.pdf

2) Add text on a specific page on a specific area:

Read a file: base.pdf

Add a text "Star Wars Rocks" at x,y coordinate 300,200 on page 2, font TimesRoman, font 10, bold

Output the file to: base_out.pdf

With this basic code, I am pretty sure I will be able to make all the iterations that I will need and will likely never bother you again. 

Votes

Translate

Translate

Report

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 ,
Apr 30, 2010 Apr 30, 2010

Copy link to clipboard

Copied

1) It wants to insert page numbers.  I am guessing it is a default, because I can't find anything in the sample code adding the page numbers. 

No, it is in the code:

            Local.text = variables.instance.footerText &"       page ["& arguments.writer.getPageNumber() &"]";

2) Your example is CREATING a PDF file, and adding the footer to it.  I tried to read an existing PDF and add the footer and I kept breaking it.  I can't get the input and the output to jive.

Yes. In my rush, I forgot you wanted manipulate an existing pdf.  PdfWriter's are for new documents, obviously. To add the footers, use a PdfStamper, like in the watermark example. Since you are using one already for the watermark, you could probably combine the operations in that same loop.

It will likely take you less time to write it than to explain it, and again, if you don't want to, no worries:

No, I prefer to help _you_ figure out how to do it. Otherwise, you may not understand what the code is doing or how fix/modify it in the future.

1) Add a footer:

Read a file: base.pdf

Add a footer "My Footer on every page" to every page of the file (no page numbers)

Output the file to: base_out.pdf


Use the watermark example as a base.  Inside the loop, add the footer code from onPageEnd().  So the code adds a watermark AND footer to each loop.  Since the footer code will not be in function, just be sure to fix the variable scopes

// do not do this in production! see memory leak article above
libpaths = [];
arrayAppend(libpaths, expandPath("/javaLoader/itext/iText-2.1.7.jar") );
loader = createObject("component", "javaLoader.JavaLoader").init(loadPaths=libpaths);

        //initialize the building blocks used in footer text
        textColor = loader.create("java.awt.Color").decode( "##800040" );
        BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");
        textFont = BaseFont.createFont(BaseFont.TIMES_ROMAN , BaseFont.WINANSI, BaseFont.EMBEDDED);
        textFontSize = 8;


        ....


        p = 0;
        while (p LT totalPages) {
            p = p + 1;
            // Prepare to place image on OVERcontent
            content = pdfStamper.getOverContent( javacast("int", p) );


            // begin watermark code ....
            // ....

            content.addImage(img);
            content.saveState();

            // ....

             // end watermark code ....


           
            // add the footer code here ***....

            content.saveState();
            content.beginText();

            .... etcetera ....

         }


         .... rest of code ...

2) Add text on a specific page on a specific area:

Read a file: base.pdf

Add a text "Star Wars Rocks" at x,y coordinate 300,200 on page 2, font TimesRoman, font 10, bold

Output the file to: base_out.pdf

With this basic code, I am pretty sure I will be able to make all the iterations that I will need and will likely never bother you again. 

It is the same concept as adding a footer. You are simply adding text at a different location. Just keep in mind iText x,y coordinates start at the lower left, not top left.

Votes

Translate

Translate

Report

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
New Here ,
May 03, 2010 May 03, 2010

Copy link to clipboard

Copied

rotflmao!!!

ok, Qui-Gon.....  Teach a man to fish, and that sort of thing, right?

I found the Page Number footer code in the CFC, did not think to look there.  I thought it would have been in the CFM.  So that's done, thanks.

I added (and modified) the footer info into the Watermark example:

--WATERMARK CODE WORKS, SO I WON'T WASTE YOUR TIME POSTING THAT--

//add the javaloader dynamic proxy library (and my iText jar) to the javaloader
libpaths = [];
arrayAppend(libpaths, expandPath("/CustCFX/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar"));
arrayAppend(libpaths, expandPath("/CustCFX/javaLoader/itext/iText-2.1.7.jar") );
  
//we HAVE to load the ColdFusion class path to use the dynamic proxy, as it uses ColdFusion's classes
loader = createObject("component", "CustCFX.javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);

//initialize the building blocks used by the custom page handler 
textColor = loader.create("java.awt.Color").decode( "##000000" );
BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");
textFont = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.EMBEDDED);

//intialize the page event handler component 
eventHandler = createObject("component", "CustCFX.betterPdfPageEventHandler.PdfPageEventHandler").init( font=textFont, fontSize=8, textColor=textColor);
eventHandler.setFooterText( "My Cool Footer - The Force is with ME!!!");
 
//we can pass in an array of strings which name all the interfaces we want out dynamic proxy to implement
interfaces = ["com.lowagie.text.pdf.PdfPageEvent"];

//get a reference to the dynamic proxy class
CFCDynamicProxy = loader.create("com.compoundtheory.coldfusion.cfc.CFCDynamicProxy");

// create a proxy that we will pass to the iText writer
eventHandlerProxy = CFCDynamicProxy.createInstance(eventHandler, interfaces);

// adding content to each page 
i = 0; 
while (i LT totalPages) { 
   i = i + 1; 

   // Prepare to place image on OVERcontent 
   content = pdfStamper.getOverContent( javacast("int", i) ); 


   // Only needed if you are changing the opacity, blending, etcetera .. 
   content.setGState(gState); 
 
   // Center the watermark. Note - using deprecated methods for CF8/iText 1.4 compatability 
   rectangle = pdfStamper.getReader().getPageSizeWithRotation( javacast("int", i) ); 
   x = rectangle.left() + (rectangle.width() - img.plainWidth()) / 2; 
   y = rectangle.bottom() + (rectangle.height() - img.plainHeight()) / 2; 
   img.setAbsolutePosition(x, y); 
 
   content.addImage(img);

   content.saveState();
   content.beginText();

   NOW WHAT?!?!

I tried: content.setPageEvent( eventHandlerProxy ); like in the Footer example, but that errored out.  I understand what is SUPPOSED to happen here, but I am not getting the syntax.  At this point, I need to apply the eventHandler to the content.  But what everything I have tried has errored out.


One thing that I have learned is that syntax is EVERYTHING with script (that's why I love ColdFusion so much, it's much more foregiving for us non-purebread programmers. 

so once I hvae initiate the beginText, what is the syntax for applying the eventHandler to content?

Votes

Translate

Translate

Report

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 ,
May 03, 2010 May 03, 2010

Copy link to clipboard

Copied

... Teach a man to fish, and that sort of thing, right?

Exactly 😉  But it is a lot simpler than you are thinking.  Forget all about page events. Those only apply if you were creating a new pdf, which you are not. So start fresh with the watermark example.  Make sure you're creating all of the iText objects with the JavaLoader, not createObject().  Then all you need to do is add a bit of code inside the loop to create the footers and you are done.

libpaths = [];

arrayAppend(libpaths, expandPath("/CustCFX/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar"));
   
loader = createObject("component", "CustCFX.javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);

Since you are not using page events anymore,  you do not need to load the proxy jar or use the loadColdFusionClassPath=true parameter.

BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");
textFont = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.EMBEDDED);

textColor = loader.create("java.awt.Color").decode( "##000000" );

So you have got your objects that will be used to draw the footer text.  Then just paste in the footer code from onEndPage inside the loop.  Obviously you have to fix up the variables. Some will not exist and others have different names. For example, "Local.cb" becomes "content",  arguments.document does not exist anymore, so you'll have to replace that part with the desired x,y position values, etectera.

Really, that is all you need to do.  You can figure out the variable parts. Let me know if you stuck with anything.


   while (i LT totalPages) {
      i = i + 1;


      content = pdfStamper.getOverContent( javacast("int", i) );

      //  do watermark image code


      // create the footer
      Local.cb.saveState();
  
      Local.cb.beginText();
      Local.cb.setColorFill( variables.instance.textColor );
      Local.cb.setFontAndSize( variables.instance.font, javacast("float", variables.instance.fontSize) );
      Local.cb.setTextMatrix( arguments.document.left(), arguments.document.bottom() - 10);
      Local.text = variables.instance.footerText &"       page ["& arguments.writer.getPageNumber() &"]";
      Local.cb.showText( Local.text );
      Local.cb.endText();
  
      Local.cb.restoreState();

   }

          

Votes

Translate

Translate

Report

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
New Here ,
May 03, 2010 May 03, 2010

Copy link to clipboard

Copied

But if I don't use the

loader = createObject("component", "CustCFX.javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);

then the statement:

BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");

generates an error because loader. does not exist.

How do I greate the variables for the font/color?

I tried leaving in the loader and the variables set fine but when I execute the content.setFontAndSize( textFont, 10 ), I get an error on that line that reads "The setFontAndSize method was not found."

So here is the code so far (I excluded the comments and the watermark info to trim it down):

<cfscript> 
savedErrorMessage = ""; 
 
fullPathToInputFile = "d:\20833P2.pdf"; 
fullPathToOutputFile =  "d:\20833P2_After.pdf"; 
 
try { 
pdfReader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(fullPathToInputFile); 
totalPages = pdfReader.getNumberOfPages(); 
  
outStream = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile); 
pdfStamper = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(pdfReader, outStream); 

libpaths = [];
arrayAppend(libpaths, expandPath("/CustCFX/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar"));
arrayAppend(libpaths, expandPath("/CustCFX/javaLoader/itext/iText-2.1.7.jar") );
   
loader = createObject("component", "CustCFX.javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);
 
textColor = loader.create("java.awt.Color").decode( "##000000" );
BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");
textFont = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.EMBEDDED);
textFontSize = 10;

i = 0; 
while (i LT totalPages) { 
   i = i + 1; 

   content = pdfStamper.getOverContent( javacast("int", i) ); 

  content.saveState();
  content.beginText();
  content.setColorFill( textColor);
  content.setFontAndSize( textFont, textFontSize );
  content.setTextMatrix( 100, 150);
  Local.text  = "Boy I hope this works";
  content.showText( Local.text  );
  content.endText();
  
  content.restoreState();
}


WriteOutput(" Finished!"); 

catch (java.lang.Exception e) { 
savedErrorMessage = e; 

// closing PdfStamper will generate the new PDF file 
if (IsDefined("pdfStamper")) { 
pdfStamper.close(); 

if (IsDefined("outStream")) { 
outStream.close(); 

</cfscript>

Votes

Translate

Translate

Report

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 ,
May 03, 2010 May 03, 2010

Copy link to clipboard

Copied

But if I don't use the

loader = createObject("component", "CustCFX.javaLoader.JavaLoader").init(loadPaths=libpaths, loadColdFusionClassPath=true);

then the statement:

BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");

generates an error because loader. does not exist.

I said you do not need the loadColdFusionClassPath _parameter_ , not that you do not need the javaLoader. (I even highlighted the parameter only in red too 😉

How do I greate the variables for the font/color?

You already did that in your code.

I tried leaving in the loader and the variables set fine but when I execute the content.setFontAndSize( textFont, 10 ), I get an error on that line that reads "The setFontAndSize method was not found."

The expected parameters for setFontAndSize are (BaseFont, float).  The value "10" is ambiguous. It could be represented by several java data types: string, integer, float, etcetera.  So CF fails to find the java method because it does not know what data type to use. Try using javaCast() to reduce the ambiguity.

                   content.setFontAndSize( textFont, javacast("float", 10) )

Votes

Translate

Translate

Report

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
New Here ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

>I said you do not need the loadColdFusionClassPath _parameter_ , not that you do not need the javaLoader. (I even highlighted the parameter only in red too 😉

You're killing me! 

As painful as that was, I am a better person for it.  I was able to do the watermark, footer and then (on my own) be able to add text at a certain X,Y coordinate on a specific page.  So in the end, you taught me to fish (little fish, but at least I understood it).

YOU ROCK!!!!!

Lastly, how do I go about "reporting a bug" because this really should have all been able to be handled by ColdFusion's AddWatermark feature.....

Votes

Translate

Translate

Report

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 ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

LATEST

and then (on my own) be able to add text at a certain X,Y

coordinate on a specific page.

That is great!

how do I go about "reporting a bug"

The public bug tracker can be found at the url below. Assuming no one has entered a bug for this already, do post the new bug number back on this thread.

http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

Though I got to thinking about the "why" of it. I am wondering if the behavior is related to the remove watermark (and headers/footers) feature. Perhaps the way in which images are added is necessary to achieve the "remove" functionality?  That is total guesswork on my part. But I am curious about it. So I will keep an eye out for the bug number.

As painful as that was, I am a better person for it.

That which does not kill us, makes us ... a stronger developer 😉

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

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
Documentation