views:

307

answers:

1

I have a dynamically generated PDF that can be in one of two modes. If in a draft mode, the only real difference is a watermark that states DRAFT on each page.

I am using a page event, so on the startpage I print the image, so that it is under everything. When I did this on the endpage event then it would be on top of everything, which was bad.

I would like to have alternating colors on the tables so that it is easier to see, but if I set the gray background to be 0.9 then it is opaque and the watermark is covered. If I set the background color to be null and the gray color is 1.0 then it is transparent.

So, my question is, on the non-white alternating rows can I get the watermark to be seen.

Ideally it would be nice to be able to place the image on top of the layer with the borders and background colors, so it would be under the text, but, it appears that isn't an option, as, when I use the stamp with the under content layer it would be under all the cells, since they all had colors set, so nothing was transparent.

UPDATE:

I haven't tried this yet, but it appears that if I save the PDF then using the PdfStamper I can save the graphics state, set the opacity for the image, then restore the graphics state, and it may work.

http://www.vbforums.com/showthread.php?t=518686

But, I don't see any way to do what I would like without saving it first, as I am actually generating and streaming directly to the browser, and would prefer not to save, if possible.

+1  A: 

By using the link in my final update I was able to get the watermark to work.

So, I save the file, then I use a MemoryStream to read in the file and I save the graphics state, set the opacity, set the watermark and then restore the graphics state.

I then stream this back to the browser and delete the file.

I haven't found any way to do it that works better than this. What is nice is that an image is not needed for the watermark, so I set the font size to 96pts, and that seemed to work fine, in landscape and portrait mode.

James Black