Situation:
- (Large) PDFs are stored on an iOS device
- The PDFs are encrypted using a Rijndahl algorithm
- When tapping one of the PDFs, it gets decrypted and afterwards viewed using a PDF viewer I implemented. The viewer is using the Core Graphics functionality to render the document page by page.
Issue:
- With the documents being large enough, encrytion will take a while.
- Viewing can only be started after the whole document has been decrypted into a temp file.
I’m wondering, if there is a way to…
- Pass some kind of stream to
CGPDFDocumentinstead of a file URL - Or any other alternative to be able to view as many pages as possible whil decrpytion is continued in the background?
If you cannot split your original PDF files down to single pages (as I suspect), then the following approach should work:
A: When still decrypting:
try to open the PDF document as you already do;
try accessing the document page you are interested in;
if it does not fail, render the page;
if it fails, then you know that page is not available yet (while decrypting);
while decrypting, release the pdf document each time you try to get a new page.
B: when decryption is done: do as you are already doing.
Please note that this is just a suggestion, I have not tried this while decrypting a document, but if point 1. does not fail, then this should work.