LazyPDFKit icon indicating copy to clipboard operation
LazyPDFKit copied to clipboard

Annotations getting applied to all the pdf's

Open neethu2092 opened this issue 10 years ago • 6 comments

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.

neethu2092 avatar Mar 31 '15 05:03 neethu2092

i have too this problem

mr-merlin avatar Aug 03 '15 07:08 mr-merlin

autor, please open to sourse code or fixed this bug

mr-merlin avatar Aug 03 '15 08:08 mr-merlin

same problem here. Any luck @irishman1921 @neethu2092 ?

acMaia avatar Aug 11 '15 13:08 acMaia

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

bastianrob avatar Nov 04 '15 09:11 bastianrob

i have the same issue, does any one have solution for this?

chitra511 avatar Sep 11 '17 08:09 chitra511

@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;
}

mfa01 avatar Jul 21 '20 12:07 mfa01