In some cases, the PDF does not display the watermark.
Result PDF's dimension it's bigger then the original PDF.
No errors are released by the library.
We cannot identify the reason why watermark it's not visible or if it not exists at all in the PDF.
Below the function used by the tool:
- Code: Select all
static void SetWaterMark(PdfPageBase page, string stampString, float trasparency, float size, int rotation, string fontFamily = "TimesRoman", string fontStyle = "Regular")
{
try
{
PdfTilingBrush brush = new PdfTilingBrush(new SizeF(page.Canvas.ClientSize.Width / 2 + page.Canvas.ClientSize.Width / 2,
page.Canvas.ClientSize.Height / 2 + page.Canvas.ClientSize.Height / 2));
brush.Graphics.SetTransparency(trasparency);
brush.Graphics.Save();
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2);
brush.Graphics.RotateTransform(rotation);
brush.Graphics.DrawString(stampString,
new PdfFont(ParseEnum<PdfFontFamily>(fontFamily), 130, ParseEnum<PdfFontStyle>(fontStyle)),
PdfBrushes.LightGray,
0,
0,
new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle));
brush.Graphics.Restore();
brush.Graphics.SetTransparency(trasparency);
page.Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), page.Canvas.ClientSize));
}
catch (Exception ex)
{
Log(ex.Message);
}
}
My best regards.