I'm writing an adobe plugin that is searching through pdf's for text that has the annotation strikeout.
I can find the annotation, but it selects text that is above and blow the text that has the strikeout.
I know PDF works in blocks, I was wondering, when I retrieve the block and the text in the block is there a way to determine what text in the block has the annotation?
Code so far :-
Any help would be extremely grateful!Code:for (int iPageCount = 0; iPageCount < iNumPages; iPageCount++)
{
//Aquire each page in the document in each round of the loop
PDPage thisPDPage = PDDocAcquirePage (thisPDDoc, iPageCount);
//Aquire PDEContent object for the page
PDEContent thisPDEContent = PDPageAcquirePDEContent(thisPDPage, gExtensionID);
//Loop through the number of annotations on the page
for (int iAnnotCount = 0; iAnnotCount < PDPageGetNumAnnots(thisPDPage); iAnnotCount++)
{
//We are only interested in annotations of type 'Strikout' as these are the annotations to be redacted
PDAnnot thisPDAnnot = PDPageGetAnnot (thisPDPage, iAnnotCount);
if(PDAnnotIsValid(thisPDAnnot) && PDAnnotGetSubtype(thisPDAnnot) == ASAtomFromString("StrikeOut"))
{
ASFixedRect thisASFixedRect;
//Get the Rectangle points for the Annotated text.
PDAnnotGetRect(thisPDAnnot, &thisASFixedRect);
//Retrieve the text from inside the rectangle.
PDTextSelect thisPDTextSelect = PDDocCreateTextSelect(thisPDDoc, iPageCount, &thisASFixedRect);
// Enumerate the text to build the linked list of words
if (thisPDTextSelect)
{
FRSelection selection;
FRSelectionContext context;
// Initialise the selection
selection.numWords = 0;
// ISSUE 5591 REWORK JP 11/01/2006 Initialise pointer
selection.words = NULL;
// Initialise the context for the text selection processing
context.pageView = pageView;
context.selection = &selection;
context.currentWord = NULL;
context.wordListTail = &context.selection->words;
PDTextSelectEnumText (thisPDTextSelect, ASCallbackCreateProto (PDTextSelectEnumTextProc, &PDTextSelectEnumTextCB), &context);
// Reset the current row/word pointers to the head of the linked list
context.currentWord = context.selection->words;
// Enumerate the quads and assigne them to words
PDTextSelectEnumQuads (thisPDTextSelect, ASCallbackCreateProto (PDTextSelectEnumQuadProc, &PDTextSelectEnumQuadCB), &context);
RedactFRSelection(thisPDEContent, selection);
FreeFRSelection(selection);
PDTextSelectDestroy(thisPDTextSelect);
PDEPath thisPDEPath = CreateStrokedAndFilledRectPDEPathFromASFixedRect(thisASFixedRect);
}
//Remove the StikeOut Annotation once it has been redacted.
PDPageRemoveAnnot(thisPDPage, iAnnotCount);
}
}
Kev.