How do I extract all annotation comments in comment pane

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

Is there a c# example of extracting all comments from the comments pane?

I just want to extract all comments from the comments pane for the current open doc without having to do a summarized comments to a txt or csv file then read the file. I already have an instance to the current open doc

PDFXEdit.IPXV_Document doc = pdfCtl.Doc;

I'm looking in the SDK, but there is no example of getting all annotations from the current do.
https://sdkhelp.pdf-xchange.com/vie ... Annotation
You can get all of the page's annotations by using
https://sdkhelp.pdf-xchange.com/vie ... e_GetAnnot
https://sdkhelp.pdf-xchange.com/vie ... nnotsCount
You do not have the required permissions to view the files attached to this post.
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How do I extract all annotation comments in comment pane

Post by Sasha - PDF-XChange »

Hello asamrith@gmail.com,

There won't be any examples for every method that you come across - plenty of them are logical and can be understood by having some basic PDF and programming knowledge. Also, we won't write every piece of code for you (this is entirely different type of work) - we only can guide you in the problems that you come across and help you solve them.

The links that you gave are not working (please check that in the future when you post links).
The comments pane only illustrates all of the comments in the document, thus you can't extract the annotations from the comments pane - you should extract the annotations from the document itself.

Also, I do not quite get what you mean by extracting all of the annotations.
You gave the methods that allow getting all of the annotations from the page. All you need to do is repeat that for each of the IPXC_Page of the IPXC_Document.
https://sdkhelp.pdf-xchange.com/vie ... ment_Pages

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

Re: How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

Apologies if I was not not clear as I'm new to using this PDFX-Editor-SDK. On the menu bar, Comments->Summarize Comments saves summarized comments to a file, txt or csv, but you have to do via command bar, Comments. How do get the summarize comments via code instead of in a file through the command bar, comments->summarize comments..

Thanks
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How do I extract all annotation comments in comment pane

Post by Sasha - PDF-XChange »

Ah, if that's what you wanted then it's easy enough. All you need to do is launch the appropriate command:

Code: Select all

pdfCtl.Inst.ExecUICmd("cmd.comments.summarize");
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

Re: How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

I really appreciate the feedback but I already know how to launch the summarize comments command via code. what I need help on is how do you get all summarize comments like below into a c# string? I need to do this so I can pass all summarize comments or pieces of it into a JSON web service. If I execute the command, summarize comments from code, then I have to read the file in a directory and parse it which I'm trying to avoid doing. Thanks.


////////////////////////////////////////////////////////////////////////////////////////////////////
// Summary of Comments on Paper
////////////////////////////////////////////////////////////////////////////////////////////////////

Page: 1
----------------------------------------------------------------------------------------------------
Page: 1
Type: Text Author: samrch Subject: Sticky Note Date: 10/31/2016, 1:56:35 PM
testing 1 2 3

Page: 1
Type: StrikeOut Author: samrch Subject: Strike-Out Date: 10/31/2016, 1:57:11 PM
testing strike out comments

Page: 1
Type: Highlight Author: samrch Subject: Highlight Date: 10/29/2016, 12:18:13 AM
test
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

Re: How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

I was able to figure it out using Alex's example from this post, https://www.pdf-xchange.com/forum3 ... 66&t=27340...here is my code to get all comments including reply comments from the current doc and comments pane.

Code: Select all

PDFXEdit.IPXV_Document doc = pdfCtl.Doc;
        if (doc == null)
            return;

        try
        {

            uint uiPageCount = doc.CoreDoc.Pages.Count;
            for (uint p = 0; p < uiPageCount; p++)
            {
                uint uiAnnotCount = doc.CoreDoc.Pages[p].GetAnnotsCount();
                for (uint i = 0; i < uiAnnotCount; i++)
                {
                    PDFXEdit.IPXC_Annotation annot = doc.CoreDoc.Pages[p].GetAnnot(i);
                    if (annot.IsMarkup)
                    {
                        PDFXEdit.IPXC_AnnotData data = annot.Data;
                        PDFXEdit.IPXC_AnnotData_Markup mData = (PDFXEdit.IPXC_AnnotData_Markup)data;

                        MessageBox.Show("Title: " + mData.Title);
                        MessageBox.Show("Subject: " + mData.Subject);
                        // comment text including reply comment
                        MessageBox.Show("Contents: " + mData.Contents);

                    }
                }
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: How do I extract all annotation comments in comment pane

Post by Sasha - PDF-XChange »

Hello asamrith@gmail.com,

Glad that you figured it out :)

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

Re: How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

How do I get the date and time from the markup comments? I have attach a screen capture file
You do not have the required permissions to view the files attached to this post.
asamrith@gmail.com
User
Posts: 91
Joined: Fri Sep 16, 2016 12:03 am

Re: How do I extract all annotation comments in comment pane

Post by asamrith@gmail.com »

I figure it out on how to get the modification date of a markup comment.

Code: Select all

PDFXEdit.IPXC_Annotation annot = doc.CoreDoc.Pages[p].GetAnnot(i);
MessageBox.Show("Modification Date" + annot.ModificationDate);
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19919
Joined: Mon Jan 12, 2009 8:07 am

Re: How do I extract all annotation comments in comment pane

Post by Stefan - PDF-XChange »

Hello asamrith,

You should be able to get the mod date using this:
https://sdkhelp.pdf-xchange.com/vie ... cationDate

P.S. You beat me to finding the solution yourself! :)

Regards,
Stefan