PDFKit doesn't return the correct page

Hello, We are experiencing on some occasions a wrong behavior with PDFDocument method: func page(at index: Int) -> PDFPage?

With certain PDF files, this method returns the wrong PDFPage. This occurs on iOS 18.3, 18.5 and 18.6.2 (an maybe on other versions). Try this PDF for instance (page 81 is returned when index = 2): https://drive.google.com/open?id=1MHm2wjfsbWB8OiRmARUMmvODYxp4DIqP&usp=drive_fs

Also, I mention that this doesn't occur systematically with this PDF. When making a copy of this file we don't observe the issue. Could this be linked some kind of internal cache issue ?

Answered by mattogrosso in 870925022

After more investigation, it appears that the issue is due to "linearized PDF". When accessing the document the following error is logged: "Failed to get linearized page dict for page" (enable CG_PDF_VERBOSE env var to see PDFKit errors)

Accepted Answer

After more investigation, it appears that the issue is due to "linearized PDF". When accessing the document the following error is logged: "Failed to get linearized page dict for page" (enable CG_PDF_VERBOSE env var to see PDFKit errors)

PDFKit doesn't return the correct page
 
 
Q