Hidden state for Comment annotations.

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

Moderator: Alex

Post Reply
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

Hidden state for Comment annotations.

Post by IntegraHarlan »

I would like to have the comment to be hidden when the associated Text annotation is set to hidden, but keep the open state the same.
I tried to change Visible to false, but that does not affect the comment.
For example if the comment is open, and I set the associated text annotation to hidden, I would like both the text annotation and the popup to be hidden, but the pop up state to still be open.
The reason why I want to do this is I want to print the comment in the open or closed state regardless of the hidden state of the associated text annotation.
If the associated text annotatin is set to hidden and the comment IsOpen is set to true, I want be able to print annotation and the comment. If the annotation is set to hidden and the comment IsOpen is set to false, I want to print the text annotation but not the comment.

Is there a way to do this?

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

Re: Hidden state for Comment annotations.

Post by Alex »

Hi Harlan,

For solving your task in PdfEditorDemo project you need to do the following steps:
  • Create custom PDF annotation comment and override logic of PdfAnnotationComment.IsOpen property.

    Code: Select all

    public class MyPdfAnnotationComment : Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationComment
    {
    
        public MyPdfAnnotationComment(
            Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationCommentCollection owner,
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfMarkupAnnotation source)
            : base(owner, source)
        {
        }
        
        
        
        public override bool IsOpen
        {
            get
            {
                if (Annotation.IsHidden)
                    return false;
                return base.IsOpen;
            }
            set
            {
                base.IsOpen = value;
            }
        }
        
    }
    
  • Create custom PDF annotation comment collection.

    Code: Select all

    public class MyPdfAnnotationCommentCollection : Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationCommentCollection
    {
    
        public MyPdfAnnotationCommentCollection(Vintasoft.Imaging.VintasoftImage image)
            : base(image)
        {
        }
        
        
        
        protected override Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationComment CreateComment(
            Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationCommentCollection owner,
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfMarkupAnnotation source)
        {
            return new MyPdfAnnotationComment(owner, source);
        }
        
    }
    
  • Create custom PDF annotation comment controller of image collection.

    Code: Select all

    public class MyImageCollectionPdfAnnotationCommentController : Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController
    {
    
        protected override Vintasoft.Imaging.Annotation.Comments.CommentCollection CreateCommentCollection(Vintasoft.Imaging.VintasoftImage image)
        {
            return new MyPdfAnnotationCommentCollection(image);
        }
        
    }
    
  • Use custom PDF annotation comment controller of image collection in PdfEditorDemo project.
    For doing this change code of InitVisualTools method in MainForm class:

    Code: Select all

    ...
    ImageViewerCommentController commentController = new ImageViewerCommentController(new ImageCollectionPdfAnnotationCommentController());
    _commentVisualTool = new CommentVisualTool(commentController, new CommentControlFactory());
    ...
    
    to the following code:

    Code: Select all

    ...
    ImageViewerCommentController commentController = new ImageViewerCommentController(new MyImageCollectionPdfAnnotationCommentController());
    _commentVisualTool = new CommentVisualTool(commentController, new CommentControlFactory());
    ...
    
Best regards, Alexander
Post Reply