Have you tried to BitBlt your Watermark instead over rendering it over and over again?
What I would do, is something like this:
- Create a transparent Bitmap in memory
- Render my Watermark string ONLY ONCE into this bitmap
- Use the BitBlt method to just "copy" my watermark on each of the pages.
It's a bit down into Windows-Api but I can at least give you the DllImport Statement for BitBlt - I have done something similar years ago - when I am at home I can take a look through my archives - maybe you have luck and I find the code, but it wasn't that hard.
StretchBlt allows you even to resize your watermark (if page sizes change, I don't know)
public const int SRCCOPY = 0xCC0020;
[DllImport("gdi32.DLL")]
public static extern int StretchBlt(IntPtr hDC, int x, int y,
int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc,
int nSrcWidth, int nSrcHeight, int dwRop);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool BitBlt(
[In()] System.IntPtr hdc, int x, int y, int cx, int cy,
[In()] System.IntPtr hdcSrc, int x1, int y1, uint rop);
You use the SRCCOPY for the dwRop/rop parameter which describes the copy strategy - and this is the fastest that supports transparency as far as I can remember.
This should increase the performance to almost-speed-of-light :) at least 5-10 times faster than drawstring I'd say, so you will be very likely down to 10-15 seconds from your 50 seconds.
Best regards,
Mike