how to hide all the annotations in a pdf file - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: how to hide all the annotations in a pdf file

how to hide all the annotations in a pdf file 1 year 3 months ago #12682

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
hi, I want to hide or remove all the annotations in a pdf file. My code is below:
Document doc = PDFGetDoc();
        int pageCount = doc.GetPageCount();
        for (int i = 0; i < pageCount; i++) {
            Page page = doc.GetPage(i);
            int annCount = page.GetAnnotCount();
            for (int j = 0; j < annCount; j++) {
                Annotation annotation = page.GetAnnot(j);
                if (annotation != null) {
                    annotation.SetHide(true);
                }
            }
        }
My question is that GetAnnot(annitationIndex) sometimes return null, so how can I remove or hide all the annotations in a pdf file, thanks

Please Log in or Create an account to join the conversation.

how to hide all the annotations in a pdf file 1 year 3 months ago #12683

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 865
  • Karma: 23
  • Thank you received: 70
You need to first call
Page.ObjsStart
Document doc = PDFGetDoc();
        int pageCount = doc.GetPageCount();
        for (int i = 0; i < pageCount; i++) {
            Page page = doc.GetPage(i);
            page.ObjsStart();
            int annCount = page.GetAnnotCount();
            for (int j = 0; j < annCount; j++) {
                Annotation annotation = page.GetAnnot(j);
                if (annotation != null) {
                    annotation.SetHide(true);
                }
            }
        }
If you still have problems, can you please share the pdf file and they way you are calling the above code?

Please Log in or Create an account to join the conversation.

Last edit: by nermeen.

how to hide all the annotations in a pdf file 1 year 3 months ago #12684

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
OK, thanks, I have a try.

Please Log in or Create an account to join the conversation.

how to hide all the annotations in a pdf file 1 year 3 months ago #12685

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
it works, thank you. :woohoo:

Please Log in or Create an account to join the conversation.

how to hide all the annotations in a pdf file 6 months 1 week ago #13793

  • 军罗
  • 军罗's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
it doesn't work here。https://www.radaeepdf.com/forum/Android-development/4067-how-to-hide-a-button-of-mutilmedia-in-pdf-file

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum