xsl-list
[Top] [All Lists]

Re: [xsl] watermarking PDF

2011-11-29 19:03:38
Thanks Ken,

So I understand this is not a straightforward thing to do.
Would it be easier if I just added it as a smaller background to the fo:region-body
and ignore the header and footer stuff?

thanks also for the iText suggestion, I will look into that

Geert



At 01:51 30/11/2011, you wrote:
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 mutually exclusive.

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(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>