Hi everyone,
I am new to Acrobat SDK and i am having a hard time trying to figure this out...
I am trying to extract the "UF" Value from "AA"(additional action) -> "D" -> "F" -> "UF" from a [Widget] type Annotation.
Below is how it is structured in the PDF:
<</AA<</D<</F 26 0 R/S/Launch/Type/Action>>>>/AP<</D 25 0 R/N 24 0 R>>/BS<</S/S/Type/Border/W 0>>/DA(/98f44ab4-3234-4e0f-9f86-c21f94d45319 12 Tf 0.392157 0.584314 0.929412 rg\r\n)/F 4/FT/Btn/Ff 65536/MK<</BC[0.0 0.0 0.0]/BG[1.0 1.0 1.0]/CA(Link to workpaper attachment: My Document)>>/P 7 0 R/Q 0/Rect[60.0 650.489 525.0 688.093]/Subtype/Widget/T(submitButton)/TU(My Document)/Type/Annot>>
<</Type/Filespec/UF(./Q2 FY 2011/Activities/My Document.DOCM)>>
Here is my code(plugin)(If someone have a another way to get this done in VB or C# please let me know how too):
//Code Begin
ACCB1 void ACCB2 MyPluginCommand(void *clientData)
{
// try to get front PDF document
AVDoc avDoc = AVAppGetActiveDoc();
if(avDoc==NULL) {
// if no doc is loaded, make a message.
strcat(str,"There is no PDF document loaded in Acrobat.");
}
else {
// if a PDF is open, get its number of pages
PDDoc mypdDoc = AVDocGetPDDoc (avDoc);
int numPages = PDDocGetNumPages (mypdDoc);
PDPage page;
PDAnnot annot;
char* showpath;
//Pdf only has one page with a widget annotation for testing
page = PDDocAcquirePage(mypdDoc, 0);
ASInt32 i2;
//Get each annotation on the page
for (i2 = 0; i2 < PDPageGetNumAnnots(page); i2++){
//Get a specific annotation
annot = PDPageGetAnnot(page,i2);
if (PDAnnotIsValid(annot)){
//Display subtype information about the annotation
if(PDAnnotGetSubtype(annot) == ASAtomFromString("Widget")){
CosObj obj;
obj = PDAnnotGetCosObj(annot);
CosObj cosAction, winDictionary, fileSpecCosObj, fileName;
ASAtom aa, f;
PDFileSpec fileSpec;
if (!(ASAtomExistsForString("AA", &aa))) aa = ASAtomFromString("AA");
if (!(ASAtomExistsForString("UF", &f))) f = ASAtomFromString("UF");
PDAction thisaction = PDLinkAnnotGetAction(CastToPDLinkAnnot(annot));
cosAction = PDActionGetCosObj(thisaction);
winDictionary = CosDictGet(cosAction, aa);
fileSpecCosObj = CosDictGet(cosAction, f);
fileName = CosDictGet(fileSpecCosObj, f);
Int32 bytes;
showpath = CosStringValue(fileName, &bytes);
}
}
}
sprintf(str,"%s", showpath);
}
// display message
AVAlertNote(str);
return;
}
When i run this plug in i t gives me the error: There was a problem reading this document(14).
Anyone can tell me what i am doing wrong in my code please?
Thanks in advance.