PdfAnnotationTool / InteractionMode and Hidden Annotations

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Moderator: Alex

Post Reply
farangkao
Posts: 6
Joined: Sun Apr 22, 2018 12:48 pm

PdfAnnotationTool / InteractionMode and Hidden Annotations

Post by farangkao » Sun Jun 24, 2018 10:03 pm

I'm trying to solve the following Problem:

- In InteractionMode = Markup , everything works like i want to, but only single selection is possible
- In Interactionmode = Edit, mutliple selection works, but also Hidden Annotations are displayed and the User can move them.

In the PDF we handle (created by another Application) Links to other Parts of the PDF are PdfLinkAnnotations and invisible,
but with Edit Mode, they can be selected and moved.
This will confuse the End-User and lead to Links not working anymore at the Place they were put in the first place.

Can you give me pointers, if it's possible to disable certain Annotations from being selected/moved by Edit Mode.

At the moment ,the only workaround would be to remove the Annotations before activating the Edit Mode ,and add them again later.

I would be also acceptable if i can interfere in the Movement of the Annotations (cancel the action or similar)

Alex
Site Admin
Posts: 1565
Joined: Thu Jul 10, 2008 2:21 pm

Re: PdfAnnotationTool / InteractionMode and Hidden Annotations

Post by Alex » Mon Jun 25, 2018 9:01 am

Hello,

For solving your task you need do the following steps:
  • Create the MyPdfAnnotationTool class, which is derived from PdfAnnotationTool class.
  • Override the PdfAnnotationTool.GetAnnotationVisibility method:
    https://www.vintasoft.com/docs/vsimagin ... ility.html
    and change annotation visibility in code of PdfAnnotationTool.GetAnnotationVisibility method.
Best regards, Alexander

farangkao
Posts: 6
Joined: Sun Apr 22, 2018 12:48 pm

Re: PdfAnnotationTool / InteractionMode and Hidden Annotations

Post by farangkao » Mon Jun 25, 2018 10:01 am

Hi Alex,

Thanks for the fast support and clever solution :)

I've tested it and it works like expected.


Actually in my PDF the problem was not that they were "Hidden" ,but "Locked".
Reading the Description: If set, do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user.
the Movement and Deletion should be disabled by default even with the Edit Mode.

But for me this Solution works now (the Locked Content is invisible anyway, so it doesn't need to be painted in the Edit Mode)
If anyone uses "Locked" with Visible Annotations, the Solution will Hide these Annotations while Edit Mode is active.
In Markup Mode the Locked Annotations are displayed and can't be moved as expected.

If anyone interested here is the complete code for "MyPdfAnnotation"

Code: Select all

        public MyPdfAnnotationTool(PdfJsApp app, bool canUseEditMode) : base(app, canUseEditMode)
        {
            
        }
        protected override bool GetAnnotationVisibility(PdfAnnotationView view)
        {
            if (InteractionMode == PdfAnnotationInteractionMode.Edit)
            {
                return !(view.Annotation.Flags.HasFlag(PdfAnnotationFlags.Hidden) ||
                         view.Annotation.Flags.HasFlag(PdfAnnotationFlags.Locked));
            }

            return base.GetAnnotationVisibility(view);
        }
But now i have to rework my Code to work with VintaSoft Annotations as well, since i the UndoManager is actually the more important feature then the Multiple-Selection (see also my Suggestion for 8.7 here)

Except you have a clever solution for that Problem also ;)

Post Reply