Free Support Forum -

Render PDF with watermark to HTML using .NET

I am using groupdocs to create simple pdf viewer. it works correct for normal pdf. but when I try to open pdf with watermark. it does not view.
you can see in attached image pdf text is not visible but watermarks are visible.
Please help me on this.

here I am attaching the project files and image of aCapture.JPG (55.6 KB)
result pdf


Please share following details so that we can further assist you:

  • Are you using GroupDocs.Viewer or GroupDocs.Watermark API in your project
  • API version (e.g. 19.10, 20.1)
  • API variant (.NET or Java)
  • Problematic PDF file
  • Sample code or application that you are using

I am using Groupdocs viewer
it is .net version
Here i am attaching the project and sample pdf

password to pdf file is
3:HcrQ5>[8_$iU7=$W-qeQmm8IEEjY=A-^[’=9u@;K)hv9Ba)_\w{@/sE<L6|t,#1EPw"6cpfP:Iv&]xTX^$H&R&xk…q[{oii?g%L:~4bvFnj(BM}LO9#BgQa<Z-}pMTbdlJW-UitFn4GCZeLh:L&kp1LQV[/}C}:y@wO:l[M3c}?J-6h?cZ#WYtbZ"?EBzQC_]Be,BtuQq0a/1*J#TFs,aZNZZCQtYd;9H:w^Z;as|W~I6u0e|f| (11.5 KB)
3.pdf (612.7 KB)

1 Like


I am not able to open the PDF file. It says password is incorrect. Can you please share screenshot of the opened PDF file? Are you expecting this output.JPG (107.7 KB)?

Can you check with this file it does not contain password.2.pdf (502.9 KB)


We are investigating this issue at our end. Your investigation ticket ID is VIEWERNET-2325. As there is any further update, you’ll be notified.


Can you please also share the sample PDF without watermark, we’ll further investigate this issue. As a workaround please enable PdfOptions.EnableLayeredRendering option as shown in the following code snippet:

using (Viewer viewer = new Viewer("sample.pdf"))
    ViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
    viewOptions.RenderComments = true;
    viewOptions.PdfOptions.EnableLayeredRendering = true;
    viewer.View(viewOptions, 1);

This is the output.JPG (107.7 KB) we are getting.

2.pdf (396.7 KB)
here is the file without watermark it works correct without watermark.
enabling EnableLayeredRendering not help
I am getting same result as you the text under the watermark is removed.
but it shows correctly on adobe pdf viewer

1 Like


Please use GroupDocs.Viewer for .NET v20.1. We cannot reproduce this issue in v20.1. You can also request a temporary license here. This (152.9 KB) may help you in getting the temp license successfully.

Thanks for the help but i Have updated to v20.1 and it is not help


Please see this (291.2 KB). We used your project and committed only one change:

options.PdfOptions.EnableLayeredRendering = true;

thanks @atirtahir3
It works. But the attached pdf file cannot open. it throws error.
I am using this code. and the password is test

private void RenderDocument(string password)

        string OutputFolderPath = "";
        string filePathFormat = Path.Combine(OutputFolderPath, "page-{0}.html");

        LoadOptions getLoadOptions = new LoadOptions(FileType.PDF);
        getLoadOptions.Password = Properties.Resources.password;
        using (Viewer viewer = new Viewer(pdfFile,getLoadOptions))
            ViewInfo info = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView());
            TotalPages = info.Pages.Count;
            HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(filePathFormat);
            options.RenderComments = true;
            options.PdfOptions.EnableLayeredRendering = true;

    }<a class="attachment" href="/uploads/groupdocs/1619">package.pdf</a> (600.6 KB)


Please attach the PDF again.

package.pdf (600.6 KB)
here is the pdf


Please have a look at this screenshot.PNG (299.8 KB). We can successfully run and render the provided PDF file (with specified password). We used API version 20.1/20.2.

But I am getting this error

System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Pdf.Annotations.AnnotationCollection.Add(Annotation annotation)
at .()
at .(BaseViewOptions )
at . (BaseViewOptions )
at GroupDocs.Viewer.Viewer.(BaseViewOptions )
at . (Func`2 , ViewOptions )
at GroupDocs.Viewer.Viewer.View(ViewOptions options)
at FormsApp.Form1.RenderDocument(String password) in C:\CFT1\FormsApp\Form1.cs:line 54


Please try to run this project. All you have to do is to add GroupDocs.Viewer for .NET DLL (20.1 or 20.2) reference in this project.

Thanks lot
it works

1 Like


You are welcome.


Your reported issue VIEWERNET-2325 is now fixed in API version 20.4. Please download latest version of the API and let us know if this issue persists.