PDFDocument string has some text in wrong order

I'm trying to find some text in a PDF document using the PDFDocument class's findString() function on a Mac running macOS 10.12.2. Sometimes strings that should be found are not found. When I print out the contents of the PDF document's string in Xcode's debug console, some of the text is in the wrong order. As an example I have some chapters in the PDF document. For some of the chapters the chapter title appears after the chapter's contents in the document's string. When I view the PDF file in a PDF viewer, the chapter title appears before its contents like it should. Some chapters in the document's string have the text in the right order.


How do I get the PDF document's string variable to show the document's text in the right order?

Replies

Same issue. If I load the document in Preview and copy sections the same problem occurs (the text is in the wrong order). If I load it in PDF Expert and copy the same text it is in the correct order.