Lumpia wrote:
Essentially, could I not just 2 different yOffsets like so:
Yes. It should work as long as the values correctly account
for the size of the first image. Using
<cfset variables.yOffset = variables.yOffset +
variables.img.getHeight()>
Just makes it more dynamic. If you ever changed the watermark
images, the code would still work without having to change hard
coded values.
Regardless of how I modify the code, it still wants to overlap
the images. Correct me if I'm wrong, but it seems like the code
within the function (img.setAbsolutePosition(xPos, yPos)) needs to
be adjusted to account if there are 2 images.
Yes, you are right in thinking that. However, it is already
taken care of by <cfset variables.yOffset = variables.yOffset +
variables.img.getHeight()>. That code adjusts the yOffset, right
before the second call, so it takes into account the height of the
first watermark. Let us say your first watermark has a height of
40. The result should be the same as if you were to adjusted the
positions manually like this:
<cfset variables.xOffset = 160>
<!--- Draw the first watermark 20pt from the top of the
crop box--->
<cfset variables.yOffset = 20>
<cfset insertWatermarkPDF( ..., variables.xOffset,
variables.yOffset, ...)>
<cfset variables.xOffset = 160>
<!--- Draw the second watermark 60pt from the top of the
crop box--->
<!--- ie yOffset = 20 + 40 (image height) --->
<cfset variables.yOffset = 60>
<cfset insertWatermarkPDF( ..., variables.xOffset,
variables.yOffset, ...)>
Try the attached example. Download these (2) sample files
from the iText site. Save them to the same directory as your CFM
script. You could use different files, but this way we know you
will get the same results.
http://itext.ugent.be/library/com/lowagie/examples/general/copystamp/ChapterSection.pdf
http://itext.ugent.be/library/com/lowagie/examples/general/copystamp/watermark.jpg
Run the example then open the file named
"ChapterSectionFinal.pdf". You should see that the second watermark
is placed below the first one.