Hi,
this code seems to work correctly, but you should call it when the pdf is closed.
If you call it when the pdf is opened, "document" var will be destroyed and the reader doesn't have a valid pdf instance anymore.
To avoid it, you can add a parameter to you method to get the current document instance.
Something like this:
+ (void)testMethod:(PDFDoc *)document
{
@try {
int pageCount = document.pageCount;
for (int i = 0; i < pageCount; i++) {
PDFPage *page = [document page:i];
[page objsStart];
int annotCount = [page annotCount];
for (int j = 0; j < annotCount; j++) {
PDFAnnot *annotation = [page annotAtIndex:j];
//NSString *code = [annotation getEditText];
NSString *replacement = @"test";
if(replacement && ![replacement isEqualToString:@"null"]){
[annotation setEditText:replacement];
}
}
page = nil;
}
} @finally {
if([document canSave]) {
[document save];
}
}
}