LazyPDFKit
LazyPDFKit copied to clipboard
Annotations getting applied to all the pdf's
Hi,
I have multiple pdf documents in my application. When I annotate a document with LazyPDFKit, the same annotations are displayed in all the pdf's in the app.
i have too this problem
autor, please open to sourse code or fixed this bug
same problem here. Any luck @irishman1921 @neethu2092 ?
I managed to fix this by adding:
if ([annotation.file.filePath isEqualToString:filePath]) {
return annotation;
}
return nil;
in LazyPDFDataManater.m
- (Annotation *)getAnnotation:(NSString *)filePath withPage:(NSNumber *)page
Not sure this is the correct way but at least it gets the job done
i have the same issue, does any one have solution for this?
@chitra511 to come late better than never here is the solution, just replace this function by this code
- (Annotation *)getAnnotation:(NSString *)filePath withPage:(NSNumber *)page
{
Annotation *annotation = nil;
NSManagedObjectContext *context = [self managedObjectContext];
NSEntityDescription *entityDesc = [NSEntityDescription entityForName:annotationEntity inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];
NSPredicate *pred =[NSPredicate predicateWithFormat:@"(page=%@)",page];
[request setPredicate:pred];
NSError *error;
NSArray *objects = [context executeFetchRequest:request
error:&error];
if ([objects count] == 0)
{
NSLog(@"PDF: No matches for annotations");
}
request= nil;
for (int i = 0; i<[objects count]; i++) {
annotation = (Annotation *)objects[i];
if ([annotation.file.filePath.lastPathComponent isEqualToString:filePath.lastPathComponent]) {
return annotation;
}
}
return nil;
}