mblanchard | Posts: 10

Failed to find PDF header: `%PDF' not found

0 votes
After reading the docs, the solution for this problem says :
Please verify that the PDF exists, and that it has not been corrupted.
I am sure that my pdf exists and is not corrupted, but is not stored in the Bundle ressources directory like the ones in the sample app. My PDFs are store in the documents folder of the device like such :
file:///Users/username/Library/Developer/CoreSimulator/Devices/E70D91EB-4FF3-42FE-AEE3-355B55F32E0E/data/Containers/Data/Application/E35E7675-FC33-408D-939F-B04BF02F733C/Documents/069-19111001-BSC.pdf
I tried many paths to open this pdf but I get this crash that says PDF not found. Is it possible to open PDFs stored in this folder ? If so, what is the correct way to build the path ? I tried starting with "/Users/..." but that still doesn't work.

Duo_Liang | Posts: 3776

Reply to: Failed to find PDF header: `%PDF' not found

0 votes
Hi Max, I was able to using absolute path, when debugging with Simulator, using Object C code.
    ESDocument *document = [[ESDocument alloc] initWithName:@"Document1" andPath:@"/Users/duoliang/Downloads/introducing oneself.pdf"];
If you print the relative path to mainBundle, you will find it's just a file path starting with "/user/.../":
NSLog(@"File path:%@",[[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]);
Duo

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off