Free Support Forum -

Adding watermarks to PDF gives font not found exception in Linux using .NET

Product Version: GroupDocs.Watermark.NET 20.7.0
OS: Ubuntu 20.04

I’ve installed the Adobe “Source Hans Sans” font to add some Chinese watermark text to a PDF file, however I’m keep getting the FontNotFoundException error.

GroupDocs.Watermark.Exceptions.FontNotFoundException: Exception of type 'GroupDocs.Watermark.Exceptions.FontNotFoundException' was thrown.
   at   .(TextState , TextWatermark )
   at   .     (TextWatermark , PdfPage ,    )
   at        (Watermark , ContentPart ,    )
   at  .(ContentPart , Watermark ,    , IDictionary`2)
   at  .(ContentPart , Watermark ,    , IDictionary`2)
   at  (ContentPart , Watermark ,    , )
   at  .     (ContentPart , Watermark ,    )
   at GroupDocs.Watermark.Contents.ContentPart.zeumdk2eqe4dcdkfe89auyve5hpn4u5v   (Watermark )
   at GroupDocs.Watermark.Watermarker.Add(Watermark watermark, WatermarkOptions options)
   at GroupDocs.Watermark.Watermarker.Add(Watermark watermark)

Then I changed the font to the per-installed ones like “DejaVu Sans”, still get the FontNotFoundException,

Here is the code snippet:

                PdfLoadOptions loadOptions = new PdfLoadOptions();
                using (Watermarker watermarker = new Watermarker(file, loadOptions))
                    TextWatermark watermark = new TextWatermark("中文测试", new Font("Source Han Sans SC", 24));
                    watermark.ForegroundColor = Color.Gray;
                    watermark.HorizontalAlignment = HorizontalAlignment.Center;
                    watermark.VerticalAlignment = VerticalAlignment.Center;
                    watermark.IsBackground = true;
                    watermark.RotateAngle = -45;
                    watermark.ScaleFactor = 1;
                    watermark.Opacity = 0.5;

                    PdfAnnotationWatermarkOptions options = new PdfAnnotationWatermarkOptions();
                    watermarker.Add(watermark, options);

I‘ve used the same font(Source Han Sans SC) successfully added watermarks to docx,xlsx,pptx,vsdx and images files, and the Chinese characters correctly rendered, only PDF file have problems, throws FontNotFoundException.

How do I add Chinese text watermark to PDF on Linux? Is there any recommended/supported fonts?

1 Like


We’re investigating this scenario. Your investigation ticket ID is WATERMARKNET-1302. As there’s any further update, you’ll be notified.