I am looking at getting the location/coordinates of an annotation and printing them.
I can get the annotation and appear to even get the coordinates but can't print them.
This is what i am trying:
ASFixedRect box;
PDAnnotGetRect(annot, &box);
ptr = (char *) &box.left;
sprintf(buf, "The annotation's location is %s", ptr);
AVAlertNote(buf);
Thanks,
Tyler
As a follow up question:
I am trying to use this method as well:
| ASBool PDRedactionGetProps(PDAnnot redactionAnnot, PDRedactParams redactionProps) |
I can get it to return true therefore to the best of my knowledge redactionProps is filled out.
How do I pull the data out of redactionProps ie in oder to get the value of the overlayText? or the pageNum? it also looks like this method will also get me the location of the annotation...by geting the redactQuads.
The error that comes tells me
Error: expression must have class type
I can do this although what gets returned is null.
PDRedactParamsRec redactionProps;
PDRedactionGetProps(annot, &redactionProps);
but then when i get my redactionProps.overlayText the returned result is null? when I do have overlay text.
Yup the sub type is redact.
Because I do this to test:
if(PDAnnotGetSubtype(annot) == ASAtomFromString("Redact") and it goes into the if statment
And when I do this atom = PDAnnotGetSubtype(annot);
ptr = (char *) ASAtomGetString(atom);
sprintf(buf, "The subtype is %s", ptr);
AVAlertNot(buf);
returns the ptr as Redact.
An Update:
As above the PDAnnotGetSubtype returns the subtype as Redact so it should indeed be a Redaction annotation.
My PDRedactionGetProps(annot, redactionProps); ;returns false
My PDRedactionGetProps(annot, &redactionProps); also returns false
My question is why doesn't this work. Is it something wrong with my PDF. I just create a blank PDF. Then I go to Advanced -> Redaction- > Mark for redaction and draw my box somewhere on the page and give it an overlay text and then save the PDF.
I then run my plugin against this PDF and the about returns false.
Is my variable annot wrong? I get it by going:
PDAnnot annot;
annot = PDGetAnnot(page, i2++)
Full code is this:
#include "PDExpT.h"
#include "PIHeaders.h"
#include "redax.h"
#include <functional>
#include <iostream>
void RedaxReports( TCHAR * path ) {
PDDoc myPDDoc = getDocument(path);
PDPage page;
ASInt32 i,i2;
PDAnnot annot;
char* ptr;
char buf[200];
ASAtom atom;
//Iterate through the PDF document page by page
for (i = 0; i < PDDocGetNumPages(myPDDoc); i ++)
{
//Get each page within the document
page = PDDocAcquirePage(myPDDoc, 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))
{
//Display subtype information about the annotation
if(PDAnnotGetSubtype(annot) == ASAtomFromString("Redact")){
atom = PDAnnotGetSubtype(annot);
//Cast the ASAtom object to a character pointer
ptr = (char*) ASAtomGetString(atom);
sprintf(buf, "The annotations subtype is %s", ptr);
AVAlertNote (buf);
try{
PDRedactParamsRec redactionProps; //Have also tried PDRedactParams redactionProps
if(PDRedactionGetProps(annot, &redactionProps)){ //Then put PDRedactionGetProps(annot, redactionProps) still returns false
sprintf(buf, "Returns True");
AVAlertNote (buf);
}
else
{
sprintf(buf, "Returns False");
AVAlertNote (buf);
}
}
catch (std::exception &cException){
AVAlertNote("ERROR");
AVAlertNote (cException.what());
}
}
}
}
}
}//RedaxReports
North America
Europe, Middle East and Africa
Asia Pacific