Hello
I tried to adapt the codes below from the internet, but as a result I get a PDF printout without watermark. I wonder where the error is. source code > https://www.pdfsharp.net/wiki/Watermark-sample.ashx
string watermark = "DENEME"; // Get an XGraphics object for drawing beneath the existing content. PdfDocument destDocument = PdfSharp.Pdf.IO.PdfReader.Open(@"D:\test\cıktı.pdf", PdfSharp.Pdf.IO.PdfDocumentOpenMode.Modify); var page = destDocument.Pages[0]; var gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append); // Get the size (in points) of the text. XFont xFontt = new Font(Font.FontFamily, 40, Font.Style, GraphicsUnit.World); var size = gfx.MeasureString(watermark,xFontt); // Define a rotation transformation at the center of the page. gfx.TranslateTransform(page.Width / 2, page.Height / 2); gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI); gfx.TranslateTransform(-page.Width / 2, -page.Height / 2); // Create a graphical path. var path = new XGraphicsPath(); // Create a string format. var format = new XStringFormat(); format.Alignment = XStringAlignment.Near; format.LineAlignment = XLineAlignment.Near; // Add the text to the path. // AddString is not implemented in PDFsharp Core. path.AddString(watermark, xFontt.FontFamily, XFontStyle.BoldItalic, 150, new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2), format); // Create a dimmed red pen. var pen = new XPen(XColor.FromArgb(128, 255, 0, 0), 2); // Stroke the outline of the path. gfx.DrawPath(pen, path); //destDocument.AddPage(gfx.PdfPage); destDocument.Save("d:/test/yeni1.pdf");