VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Annotation.Comments.Pdf Namespace / PdfAnnotationComment Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfAnnotationComment Class
    In This Topic
    Provides a comment that stores data in PdfMarkupAnnotation and PdfPopupAnnotation annotations.
    Object Model
    PdfMarkupAnnotation PdfPage CommentCollection CommentCollection Comment PdfAnnotationComment
    Syntax
    'Declaration
    
    Public Class PdfAnnotationComment
       Inherits Vintasoft.Imaging.Annotation.Comments.Comment
    
    
    public class PdfAnnotationComment : Vintasoft.Imaging.Annotation.Comments.Comment
    
    
    public __gc class PdfAnnotationComment : public Vintasoft.Imaging.Annotation.Comments.Comment*
    
    
    public ref class PdfAnnotationComment : public Vintasoft.Imaging.Annotation.Comments.Comment^
    
    
    Example

    This C#/VB.NET code shows how to print comments to the annotations of PDF document.

    
    ''' <summary>
    ''' Demonstrates how to prints comments of specified PDF document.
    ''' </summary>
    Public Class PdfAnnotationCommentExample
        ''' <summary>
        ''' Prints comments of specified PDF document.
        ''' </summary>
        ''' <param name="pdfFilename">The PDF filename.</param>
        Public Shared Sub PrintComments(pdfFilename As String)
            ' create an image collection
            Using images As New Vintasoft.Imaging.ImageCollection()
                ' add PDF document to the image collection
                images.Add(pdfFilename)
    
                ' create PDF annotation comment controller
                Using pdfAnnotationCommentController As New Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController()
                    ' specify that PDF annotation comment controller is associated with image collection
                    pdfAnnotationCommentController.Images = images
    
                    ' print comments from PDF annotation comment controller
                    PrintComments(pdfAnnotationCommentController)
                End Using
    
                ' clear and dispose images
                images.ClearAndDisposeItems()
            End Using
        End Sub
    
        ''' <summary>
        ''' Prints comments from specified comment controller.
        ''' </summary>
        ''' <param name="commentController">The comment controller.</param>
        Public Shared Sub PrintComments(commentController As Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController)
            ' for each image
            For i As Integer = 0 To commentController.Images.Count - 1
                Dim image As Vintasoft.Imaging.VintasoftImage = commentController.Images(i)
    
                ' get comment collection, which is associated with image/PDF page
                Dim comments As Vintasoft.Imaging.Annotation.Comments.CommentCollection = commentController.GetComments(image)
                ' if comments are found
                If comments IsNot Nothing AndAlso comments.Count > 0 Then
                    System.Console.WriteLine(String.Format("Page {0}:", i + 1))
    
                    ' for each comment
                    For Each comment As Vintasoft.Imaging.Annotation.Comments.Comment In comments
                        ' print comment
                        PrintComment(comment, 0)
                    Next
                End If
            Next
        End Sub
    
        ''' <summary>
        ''' Prints the comment.
        ''' </summary>
        ''' <param name="comment">The comment.</param>
        ''' <param name="replyLevel">The reply level.</param>
        Private Shared Sub PrintComment(comment As Vintasoft.Imaging.Annotation.Comments.Comment, replyLevel As Integer)
            ' print comment
            System.Console.Write(String.Empty.PadLeft(replyLevel * 4))
            System.Console.WriteLine(String.Format("[{0}] {1}: {2} ({3})", comment.Type, comment.UserName, comment.Text, comment.ModifyDate))
    
            ' if comment has replies
            If comment.Replies IsNot Nothing Then
                ' print replies
                For Each reply As Vintasoft.Imaging.Annotation.Comments.Comment In comment.Replies
                    PrintComment(reply, replyLevel + 1)
                Next
            End If
        End Sub
    
    End Class
    
    
    
    /// <summary>
    /// Demonstrates how to prints comments of specified PDF document.
    /// </summary>
    public class PdfAnnotationCommentExample
    {
        /// <summary>
        /// Prints comments of specified PDF document.
        /// </summary>
        /// <param name="pdfFilename">The PDF filename.</param>
        public static void PrintComments(string pdfFilename)
        {
            // create an image collection
            using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
            {
                // add PDF document to the image collection
                images.Add(pdfFilename);
    
                // create PDF annotation comment controller
                using (Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController pdfAnnotationCommentController =
                    new Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController())
                {
                    // specify that PDF annotation comment controller is associated with image collection
                    pdfAnnotationCommentController.Images = images;
    
                    // print comments from PDF annotation comment controller
                    PrintComments(pdfAnnotationCommentController);
                }
    
                // clear and dispose images
                images.ClearAndDisposeItems();
            }
        }
    
        /// <summary>
        /// Prints comments from specified comment controller.
        /// </summary>
        /// <param name="commentController">The comment controller.</param>
        public static void PrintComments(Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController commentController)
        {
            // for each image
            for (int i = 0; i < commentController.Images.Count; i++)
            {
                Vintasoft.Imaging.VintasoftImage image = commentController.Images[i];
    
                // get comment collection, which is associated with image/PDF page
                Vintasoft.Imaging.Annotation.Comments.CommentCollection comments = commentController.GetComments(image);
                // if comments are found
                if (comments != null && comments.Count > 0)
                {
                    System.Console.WriteLine(string.Format("Page {0}:", i + 1));
    
                    // for each comment
                    foreach (Vintasoft.Imaging.Annotation.Comments.Comment comment in comments)
                    {
                        // print comment
                        PrintComment(comment, 0);
                    }
                }
            }
        }
    
        /// <summary>
        /// Prints the comment.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <param name="replyLevel">The reply level.</param>
        private static void PrintComment(Vintasoft.Imaging.Annotation.Comments.Comment comment, int replyLevel)
        {
            // print comment
            System.Console.Write(string.Empty.PadLeft(replyLevel * 4));
            System.Console.WriteLine(string.Format("[{0}] {1}: {2} ({3})",comment.Type, comment.UserName, comment.Text, comment.ModifyDate));
    
            // if comment has replies
            if (comment.Replies != null)
            {
                // print replies
                foreach (Vintasoft.Imaging.Annotation.Comments.Comment reply in comment.Replies)
                    PrintComment(reply, replyLevel + 1);
            }
        }
    
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Annotation.Comments.Comment
          Vintasoft.Imaging.Annotation.Comments.Pdf.PdfAnnotationComment

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also