Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
You can use AVDocCopyAnnot or AVDocCopyAnnotCommon.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now