-
1. Re: Get location of an annotation
lrosenthApr 3, 2012 5:34 PM (in response to tyerlv123)
1 person found this helpfulYou can’t print them because you are trying to treat an ASFixed value as a char*. Clearly that’s wrong.
You should convert them from ASFixed to something standard like a float (ASFixedToFloat is your friend!) and then use the %f for sprintf.
-
2. Re: Get location of an annotation
tyerlv123 Apr 3, 2012 8:05 PM (in response to lrosenth)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.
-
3. Re: Get location of an annotation
lrosenthApr 4, 2012 3:33 AM (in response to tyerlv123)
It’s a structure, so just reference the members. (props.size, etc)
-
4. Re: Get location of an annotation
tyerlv123 Apr 4, 2012 9:01 AM (in response to lrosenth)I believe that is what I am trying:
PDRedactParams redactionProps;
PDRedactionGetProps(annot, redactionProps);
ASText overlay;
overlay = redactionProps.overlayText
But it doesn't like redactionProps.overlayText...isn't that how you would reference the members?
-
5. Re: Get location of an annotation
lrosenthApr 4, 2012 9:18 AM (in response to tyerlv123)
Sounds like you are having C/C++ development issues, not related to our SDK.
-
6. Re: Get location of an annotation
tyerlv123 Apr 4, 2012 9:48 AM (in response to lrosenth)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.
-
7. Re: Get location of an annotation
lrosenthApr 4, 2012 9:49 AM (in response to tyerlv123)
And the annotation you have is indeed of Subtype Redaction??
-
8. Re: Get location of an annotation
tyerlv123 Apr 4, 2012 10:04 AM (in response to lrosenth)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.
-
9. Re: Get location of an annotation
tyerlv123 Apr 5, 2012 2:39 PM (in response to tyerlv123)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
-
10. Re: Get location of an annotation
lrosenthApr 5, 2012 3:17 PM (in response to tyerlv123)
You have to fill in the redactionProps.size member to the sizeof(PDRedactParams)
-
11. Re: Get location of an annotation
tyerlv123 Apr 10, 2012 4:04 PM (in response to lrosenth)Sorry thought the rest would be simple but alas another question relating to the initial question about the location of the box.
How do I use the redactQuads? and numQuads members?
More specially get the data out of the redactQuads.
ASFixedQuad *rect;
rect = redactionProps.redactQuads;
-
12. Re: Get location of an annotation
lrosenthApr 11, 2012 3:49 AM (in response to tyerlv123)
You have the data right there – now use them as coordinate sets on the page. Not sure what you are missing?
-
13. Re: Get location of an annotation
tyerlv123 Apr 11, 2012 8:47 AM (in response to lrosenth)Im trying to print the coordinate sets.
-
14. Re: Get location of an annotation
lrosenthApr 11, 2012 8:59 AM (in response to tyerlv123)
Remember to convert Fixed to something that you can print (like a float).
-
15. Re: Get location of an annotation
tyerlv123 Apr 11, 2012 10:10 AM (in response to lrosenth)But I can't access the members of rect? ie rect.bl
-
16. Re: Get location of an annotation
lrosenthApr 11, 2012 10:20 AM (in response to tyerlv123)
Top, left, bottom, right.