Comments for Annotations => Support for Displaying

Hello,

i work with the SDK and the WPf-control for displaying annotations from documents. When i use the the standard popup-annotation from the control, then i have the problem, that the popup didn't show the comments of pdfs.

document
->comment 1
->comment 2
-->comment 2.1
-->comment 2.2

I know that the information are saved in the document but not displayed.

There is any way to display it?

Daniel

Hello Daniel,

I am not entirely sure what you mean by this post. There are several things in PDF’s that can be referred to as comments. Comments directly in a document (sort of like comments in source code) don’t usually get displayed.

Annotations can have comments associated with them, and then there’s the sticky notes.

If you are talking about the little popup menu that comes up when you double click a StickyNote annotation or when you select some other annotation and click on note in the context menu, then the problem might be that our tools don’t look at the contents of the annotation to get the text for the popup. Instead they host a popup annotation, whose contents are displayed in the text box.
i.e. Annot → Popup → Contents.
Here’s the source code for the tools: http://pdftron.com/ID-zJWLuhTffd3c/PDFNetCLI2/Tools-6.0.1/Tools.zip
Check out TextBox CreateTextBox() in the NoteHost class, in NoteHost.cs to see what is going on. The Markup class does have SetContents and GetContents functions, so there’s nothing stopping you from modifying this

If this does not help, please clarify what you mean, and perhaps send us a pdf, along with a set of steps you’re taking and what you would expect to see.

Best Regards,
Tomas Hofmann

Hello Thomas,

i try to explain exactly what i mean.

The picture shows a comment what i made with a pdf-viewer. When i used the SDK then i get the follow picture:

The information that the comment has a answer is not displayed. So i wont build an new popup with the function to display the comment structure.

When i used the sdk to get all annotations from the document i get the following:

1. Annots.Text

→ Content: Question

→ Titel:

2. Annots.PopUp

→ Content: Question

→ Parent: 1.

3. Annot.Text

→ Content: Answer

→ Titel: Daniel

4. Annot.PopUp

→ Content: Answer

→ Parent: 3.

The first question is how i can identify that the text by number 3 is a answer of the comment text by number 1.

The secound question is how i can override the popup which is display in the sdk picture above.

I hope you understand my questions.

Daniel

Hi Daniel,

To match of annotations that are replies to earlier annotations you want to look for the IRT and RT dictionary entries. The IRT is the “In Response To” entry and specified the previous comment. The RT entry is the “Reply Type”, of which there are two, R and Group. See the PDF spec for more on them, though I suspect you would only have to worry about R type. R is the default.

Note that the original annotation has no reference to the first reply, so basically you would have to work your way forwards to get the full chain.

See the Markup Annotation entries in any PDF spec starting at PDF 1.5, for details. You can also use our COSEdit tool that comes with PDFNet for Desktop.

Finally, this is an old posting somewhat related to this subject that you might find useful.
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/IRT/pdfnet-sdk/PndHkcXORgo/j-vkeyXPEaoJ

In order to change this in the tools source code, you might want to take a look at the NoteHost class. What that class does is that it creates the yellow widget from your screenshot and adds the content from the popup attached to annotation 1.
What you will have to do is to at this point look at the page that the annotation is on, loop through the annotations and look for these IRT and RT fields and then edit the way the note is displayed.

Best Regards,
Tomas Hofmann

Hello Thomas,

thank you for your help. Now i have find the way to show me the structure auf annotations and they replies. I have a problem when i try to add a replay with code.

I try it with the following code:

private static void CreateReply(PDFDoc doc, Annot annot)
{
var txt = pdftron.PDF.Annots.Text.Create(doc, new Rect(161, 388, 180, 406), “Hello World”);
var pop = pdftron.PDF.Annots.Popup.Create(doc, new Rect(272, 300, 450, 450));
pop.SetParent(txt);
txt.SetPopup(pop);
txt.SetColor(new ColorPt(1, 0, 0));
txt.GetSDFObj().Put(“IRT”, annot.GetSDFObj().Find(“NM”).Value());
txt.RefreshAppearance();

var page = doc.GetPage(annot.GetPage().GetIndex());

page.AnnotPushBack(txt);
page.AnnotPushBack(pop);
}

I thought after reading the specification it is enought to add the IRT value to the reply annotation and push it in the same page. but when i open the pdf document in a reader then i have an extra popup with text!
What is the right way to add replies through the code.

Daniel
Am Freitag, 18. Oktober 2013 01:23:14 UTC+2 schrieb Tomas Hofmann:

Hi Daniel,

To match of annotations that are replies to earlier annotations you want to look for the IRT and RT dictionary entries. The IRT is the “In Response To” entry and specified the previous comment. The RT entry is the “Reply Type”, of which there are two, R and Group. See the PDF spec for more on them, though I suspect you would only have to worry about R type. R is the default.

Note that the original annotation has no reference to the first reply, so basically you would have to work your way forwards to get the full chain.

See the Markup Annotation entries in any PDF spec starting at PDF 1.5, for details. You can also use our COSEdit tool that comes with PDFNet for Desktop.

Finally, this is an old posting somewhat related to this subject that you might find useful.
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/IRT/pdfnet-sdk/PndHkcXORgo/j-vkeyXPEaoJ

In order to change this in the tools source code, you might want to take a look at the NoteHost class. What that class does is that it creates the yellow widget from your screenshot and adds the content from the popup attached to annotation 1.
What you will have to do is to at this point look at the page that the annotation is on, loop through the annotations and look for these IRT and RT fields and then edit the way the note is displayed.

Best Regards,
Tomas Hofmann

On Thursday, October 17, 2013 3:22:26 AM UTC-7, Daniel Lutz wrote:

Hello Thomas,

i try to explain exactly what i mean.

The picture shows a comment what i made with a pdf-viewer. When i used the SDK then i get the follow picture:

The information that the comment has a answer is not displayed. So i wont build an new popup with the function to display the comment structure.

When i used the sdk to get all annotations from the document i get the following:

1. Annots.Text

→ Content: Question

→ Titel:

2. Annots.PopUp

→ Content: Question

→ Parent: 1.

3. Annot.Text

→ Content: Answer

→ Titel: Daniel

4. Annot.PopUp

→ Content: Answer

→ Parent: 3.

The first question is how i can identify that the text by number 3 is a answer of the comment text by number 1.

The secound question is how i can override the popup which is display in the sdk picture above.

I hope you understand my questions.

Daniel

Hi Daniel,

First, the IRT entry for all reply objects, is a link to the original annotation. The order from then is based on the order of the annotations themselves. Below is fixed up python code

def add_reply(doc, annot, reply_text):
rect = annot.GetRect() # replies can just share the original’s rectangle
txt = Text.Create(doc.GetSDFDoc(), rect, reply_text)
popup = Popup.Create(doc.GetSDFDoc(), rect)
popup.SetParent(txt)
txt.SetPopup(popup)
txt.GetSDFObj().Put(‘IRT’, annot.GetSDFObj()) # the PDF object number of the original annotation being replied to. This would be the same for all replies in the “chain”
annot.GetPage().AnnotPushBack(txt)
annot.GetPage().AnnotPushBack(popup)

Hope this helps

Hello

thanks for helping. Now i can readthe structure. But i have a problem with adding annotation from code.

I do the same like the code from Ryan. But after AnnotPshBack() function,

i try to get the NM value to get the unique
identifier.

_annot.GetSdfObj().Find(“NM”).value().GetAsPdfText();

When i added the annotation then i get an exception because no value existing. But when i add
the annotation with a extern pdf viewer (like acrobat) then i get a NM-value with the
function. How i can add a NM Value on the right way to the annotation?

Greetings
Daniel
Am Montag, 14. Oktober 2013 17:03:26 UTC+2 schrieb Daniel Lutz:

Hello,

i work with the SDK and the WPf-control for displaying annotations from documents. When i use the the standard popup-annotation from the control, then i have the problem, that the popup didn’t show the comments of pdfs.

document
->comment 1
->comment 2
–>comment 2.1
–>comment 2.2

I know that the information are saved in the document but not displayed.

There is any way to display it?

Daniel

You can add “NM” (i.e. The annotation name, a text string uniquely identifying it among all the annotations on its page.) with

Obj o = annot.GetSdfObj();

o.PutText(“NM”, “ID289489”).

to get the values use

Obj nm = o.FindObj(“NM”);
if (nm != null) {
string val = nm.GetAsPdfText();
}

For more examples of how to use SDF/Cos API see SDF sample project as well as http://www.pdftron.com/pdfnet/intro.html