Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

add annotations based on the existing annotation on the page

Guest
Apr 16, 2017 Apr 16, 2017

Dear Adobe,

I want to add annotations based on the existing annotation on the page, and I want to inherit the appearance of that annotation to add the new one. Here is my code for doing this. I try to use the function PDAnnotFromCosObj to get the CosObj of the existing annotation "annot", but I tried and nothing happened, could you please tell me is it a good way to copy the existing annotation's property to creating a new annotation? Do I need to use PDPageCreateAnnot to create a new one? My existing annotation "annot" is valid and created by using cosobj dict to set the appearance by another program.

CosObj cosAnnot = PDAnnotGetCosObj(annot);

CosDoc cosDoc = CosObjGetDoc(cosAnnot);

PDAnnot Newannot = PDAnnotFromCosObj(cosAnnot);

ASText titleText = ASTextNew();

sprintf(setbuf, "Fang");

ASTextSetPDText(titleText, setbuf);

PDTextAnnotSetContentsASText(Newannot, titleText);

PDPageAddAnnot(page, -2, Newannot);

Best Regards/Bien Cordialement

Alex Fang

TOPICS
Acrobat SDK and JavaScript
506
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2017 Apr 17, 2017

What do you mean by "nothing happened"? What were your expected results and actual results? I doubt you can use the same Cos object for two different Annots though, what could be gained from two identical Annots?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 17, 2017 Apr 17, 2017

nothing happened means no new annotation created. I have put new content for the new annotation, so these two annots are different, not identical. What I want to know is the function PDAnnotFromCosObj will "create" new annot or not?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2017 Apr 18, 2017
LATEST

You can use AVDocCopyAnnot or AVDocCopyAnnotCommon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2017 Apr 18, 2017

No, PDAnnotFromCosObj is not a creator of annotations. It is more like a typecast. My point is that this Cos object is already in an annotation dictionary, so you cannot use any method to create an annotation from it. If you succeed in changing it, it can only change the original existing annotation. So I cannot imagine what you expect PDPageAddAnnot to do in this case.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines