My company (KiteEdge) has recently purchased a license of Spire.PDF . We are using Spire.PDF to watermark PDF documents. One of our end users observed that the water mark text is being truncated.
The attached file Results.zip was watermarked with the text "Contoso Private Limited". However, the watermark comes up as "Contoso" only.
Any suggestions?
Sample code
- Code: Select all
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string text = "Contoso Private Limited";
StampFile("Demo.pdf","Results.pdf",text);
}
private static void StampFile(string fileIn,string fileOut,string waterMark)
{
if (System.IO.File.Exists(fileOut)) System.IO.File.Delete(fileOut);
float fontht = 48;
using (var doc = new Spire.Pdf.PdfDocument(fileIn))
{
foreach (PdfPageBase page in doc.Pages)
{
PdfTilingBrush brush
= new PdfTilingBrush(new SizeF(page.Canvas.ClientSize.Width / 2, page.Canvas.ClientSize.Height / 3));
brush.Graphics.SetTransparency(0.3f);
brush.Graphics.Save();
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2);
brush.Graphics.RotateTransform(-45);
brush.Graphics.DrawString(waterMark,
new PdfFont(PdfFontFamily.Helvetica, fontht), PdfBrushes.Violet, 0, 0,
new PdfStringFormat(PdfTextAlignment.Left));
brush.Graphics.Restore();
brush.Graphics.SetTransparency(1);
page.Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), page.Canvas.ClientSize));
}
doc.SaveToFile(fileOut);
}
}
Sample documents
Refer attachments. I have provided the input PDF (Source.pdf) and water marked PDF (results.zip)
Thanks,
Saurabh