Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

how to hide all the annotations in a pdf file 6 years 8 months ago #12682

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 6 years 8 months ago #12683

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
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 6 years 8 months ago #12684

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 6 years 8 months ago #12685

  • glzlaohuai
  • glzlaohuai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 5 years 11 months ago #13793

  • 军罗
  • 军罗's Avatar
  • Offline
  • New Member
  • New Member
  • 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