Article View: adobe.acrobat.sdk
Article #26How to determine unique information each Atom of Anote? (VC 2005)
From: dungbkhn02
Date: Tue, 12 May 2009 12:36
Date: Tue, 12 May 2009 12:36
113 lines
4333 bytes
4333 bytes
How to determine unique information each Atom of Anote?
This my code, and I see all information of Atom CAN change when I
change anotation--> So can't determine Unique ID of an Atom
ACCB1 void ACCB2 MyPluginCommand(void *clientData)
{
// get this plugin's name for display
ASAtom NameAtom = ASExtensionGetRegisteredName (gExtensionID);
const char * name = ASAtomGetString(NameAtom);
char str[256];
sprintf(str,"This menu item is added by plugin %s.\n", name);
// 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.");
// display message
AVAlertNote(str);
}
else {
// if a PDF is open, get its number of pages
PDDoc pdDoc = AVDocGetPDDoc (avDoc);
int numPages = PDDocGetNumPages (pdDoc);
sprintf(str,"%sThe front PDF document has %d pages.", str,
numPages);
// display message
AVAlertNote(str);
PDPage page;
ASInt32 i,i2;
PDAnnot annot;
char* subtypeStr;
char buf[2000];
ASAtom atom;
CosObj cos;
CosObj dictEntry;
char subjBuf[256];
char* strValue;
ASTCount length;
char * annBuf;
ASTimeRec asDate;
char dateBuf[128];
char *titleAnnBuf;
ASInt32 titleBufSize;
//Iterate through the PDF document page by page
for (i = 0; i < PDDocGetNumPages(pdDoc); i ++){
//Get each page within the document
page = PDDocAcquirePage(pdDoc, i);
//Get each annotation on the page
for (i2 = 0; i2 < PDPageGetNumAnnots(page); i2++) {
//Get a specific annotation
annot = PDPageGetAnnot(page,i2);
if (PDAnnotIsValid(annot)){
//Annotation's Subject
subjBuf[0]=0x00;
cos = PDAnnotGetCosObj(annot);
if (CosDictKnown(cos, ASAtomFromString("Subj"))){
dictEntry = CosDictGet(cos, ASAtomFromString("Subj"));
strValue = CosStringValue(dictEntry, &length);
sprintf(subjBuf, "%s", strValue);
//Subtype
atom = PDAnnotGetSubtype(annot);
//Cast the ASAtom object to a character pointer
subtypeStr = (char*) ASAtomGetString(atom);
//Annotation's Text
ASInt32 bufSize = PDTextAnnotGetContents(annot, NULL, 0) +1;
//Allocate the size of bufSize to the character pointer
annBuf = (char*)ASmalloc((os_size_t)bufSize);
//Populate annBuf with the annotation's text
PDTextAnnotGetContents(annot, annBuf, bufSize);
//Annotation's Time;
dateBuf[0]=0x00;
if (PDAnnotGetDate(annot, &asDate)){
sprintf(dateBuf, "%02u/%02u/%4u %02u:%02u:%02u", asDate.month,
asDate.date, asDate.year, asDate.hour, asDate.minute, asDate.second);
}
//Annotation's Title
titleBufSize = PDAnnotGetTitle(annot, NULL, 0) +1;
titleAnnBuf = (char*)ASmalloc((os_size_t)titleBufSize);
PDAnnotGetTitle(annot, titleAnnBuf, titleBufSize);
sprintf(buf, "Page [%i]\nAnnot [%li][%li]\nAtom [%u]\nSubType
[%s]\nContents [%s]\nDate [%s]\nTitle [%s]\nSubject [%s]", i+1,
annot.a, annot.b, atom, subtypeStr, annBuf, dateBuf, titleAnnBuf,
subjBuf);
AVAlertNote (buf);
}
}
}
}
}
return;
}
-----------
Thanks in advanced!
Technical Details
Message-ID:
<043b21a5-3c20-433e-a475-4c8543de314e@d7g2000prl.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!d7g2000prl.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!d7g2000prl.googlegroups.com!not-for-mail From: dungbkhn02@gmail.com Newsgroups: adobe.acrobat.sdk Subject: How to determine unique information each Atom of Anote? (VC 2005) Date: Tue, 12 May 2009 05:36:56 -0700 (PDT) Organization: http://groups.google.com Lines: 113 Message-ID: <043b21a5-3c20-433e-a475-4c8543de314e@d7g2000prl.googlegroups.com> NNTP-Posting-Host: 117.0.4.129 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1242131816 16761 127.0.0.1 (12 May 2009 12:36:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 12 May 2009 12:36:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d7g2000prl.googlegroups.com; posting-host=117.0.4.129; posting-account=nGYqowoAAAAGFhIEq9J9kXMmJvj9aW4N User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe)