Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Oct 11, 2019 11:19 am

Hi All,
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
Results.zip
Input.zip

saurabhd
 
Posts: 6
Joined: Tue Aug 27, 2019 8:37 am

Sat Oct 12, 2019 2:12 am

Hi,

Thanks for your inquiry.
Please try to reduce the font size and change the text alignment. I changed your font size to "32" and set the text alignment as "Center", and your long text watermark(Contoso Private Limited) could be displayed completely. I have attached my result Pdf file, please check it.
Below is the code for your reference.

Code: Select all
            float fontht = 32;
            brush.Graphics.DrawString(waterMark,new PdfFont(PdfFontFamily.Helvetica, fontht), PdfBrushes.Violet, 0, 0, new PdfStringFormat(PdfTextAlignment.Center));



Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Sun Oct 13, 2019 8:50 am

Yes.This is much better. It would be good to have some documentation of how the parameters effect the output. The repetition of the water mark, starting point of the fist text block, etc. I had to try out various combinations.

Thank you.

saurabhd
 
Posts: 6
Joined: Tue Aug 27, 2019 8:37 am

Mon Oct 14, 2019 9:44 am

Hi,

Thanks for your reply.
Actually we have API document, please download it from the following link.
http://www.e-iceblue.com/downloads/atta ... df-API.zip

If you encounter any issue, please feel free to contact us with detailed information. We will update you ASAP after an investigation.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Dec 03, 2019 9:04 am

Hi,

Greetings from E-iceblue.
How's your issue going? Could you please give us some feedback at your convenience?

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.PDF