PdfDocument document = PdfReader.Open(fileName, PdfDocumentOpenMode.Modify); string watermark = waterText; PdfPage page = document.Pages[document.PageCount-1]; XFont font = new XFont("Arial", 6, XFontStyle.Bold); XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend); XSize size = gfx.MeasureString(watermark, font);
gfx.TranslateTransform(50, 50); gfx.RotateTransform(-90);
// Create a string format XStringFormat format = new XStringFormat(); format.Alignment = XStringAlignment.Near; format.LineAlignment = XLineAlignment.Near;
// Create a dimmed red brush XBrush brush = new XSolidBrush(XColor.FromArgb(Color.Black));
// Draw the string gfx.DrawString(watermark, font, brush, new XPoint(100-page.Height, page.Width - 80), format);
when i use the DrawString method,sometimes the watermark is covered by something, like pictures.
hou can I use the DrawString method to put the watermark always in the front?
Thanks.
|