Re: [xsl] watermarking PDF
At 2011-11-30 01:41 +0100, Geert Bormans wrote:
What would be the best way to add a watermark to a PDF using xsl:fo?
Something like "Confidential" accross the page
I assume I need to make an image and use a background-image
Sticking to XSL-FO, yes, but ....
How can I make that almost fill the page (given I also have header and footer)
By segmenting the graphic into the different region dimensions and
giving applying the different fragments to the regions.
Not pretty. And there are no scaling facilities in the standard
XSL-FO vocabulary for the image background. And who knows if the
registration of the rendered images would look seamless?
In my work I use a post-process on the PDF using iText to add the watermark.
If you knew the Z-level of the regions produced by your formatter
(the region Z-levels are not standardized and vary between different
products), you could create overlapping regions. Say, make the
"start" region the size of the page, and then render a scaled image
in that region. If that region's Z-level is below the body region,
then you'll get a watermark effect (if not, it will obscure your content).
Note that technically you would be triggering an error condition, so
the formatter may not support you on this: the foreground of any one
region is not supposed to occupy the same printed dot as the
foreground of any other region. This is not a problem with the
backgrounds, only the foregrounds. When I use overlapping regions
for my UBL invoice rendering, I make sure the foregrounds are
So, I suppose, you could have a single overlapping "start" region
behind your body, header and footer regions, and then put your one
non-fragmented image into the start region background .... *if* the
Z-level of the start region is lower than that of the other three
regions for your vendor's tool.
Would that work for both FOP and AntennaHouse?
Would .jpg be the best image format
I don't think there is a "best" ... JPG would be nice and small
compared to, say, TIFF.
I hope this helps.
. . . . . . . . . . . . . Ken
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal