🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.acrobat.sdk
1 messages
1 total messages Started by dungbkhn02 Tue, 12 May 2009 12:36
How to determine unique information each Atom of Anote? (VC 2005)
#26
Author: dungbkhn02
Date: Tue, 12 May 2009 12:36
113 lines
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!
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads