PDFBOX-1813: reverted most of the changes of revision 1557544 as it introduced several regressions (see PDFBOX-1865 and PDFBOX-1892)