0

In this code a PSPDFDocument is showing as not valid even though the file exists (and I know it's not password protected). Not sure why this would happen

+ (PSPDFDocument *)fromDocument:(Document *)doc
{
    NSString * path = [doc getFilePath];
    PSPDFDocument * pspdfdoc = [PSPDFDocument documentWithURL:[NSURL fileURLWithPath:path]];

    pspdfdoc.document = doc;
    if ([pspdfdoc isValid])
        DELogVerbose(@"Valid");
    else
    {
        DELogVerbose(@"Not Valid");

        NSFileManager *fileManager = [NSFileManager defaultManager];

        DELogVerbose([fileManager fileExistsAtPath:path] ? @"File exists" : @"File does not exist");
    }

    return pspdfdoc;
}
Mason11987
  • 330
  • 2
  • 12

1 Answers1

0

Since we've already answered this on our support portal, I also wanted to write a small writeup here. The PDF was password protected, so while setup and the path were correct, isValid returns false until the document is unlocked with the correct password. (via unlockWithPassword:)

steipete
  • 7,581
  • 5
  • 47
  • 81