1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 07:38:07 +02:00

Build a fallback ToUnicode map for simple fonts (issue 8229)

In some fonts, the included `ToUnicode` data is incomplete causing text-selection to not work properly. For simple fonts that contain encoding data, we can manually build a `ToUnicode` map to attempt to improve things.

Please note that since we're currently using the `ToUnicode` data during glyph mapping, in an attempt to avoid rendering regressions, I purposely didn't want to amend to original `ToUnicode` data for this text-selection edge-case.
Instead, I opted for the current solution, which will (hopefully) give slightly better text-extraction results in PDF file with incomplete `ToUnicode` data.

According to the PDF specification, see [section 9.10.2](http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1873172):

> A conforming reader can use these methods, in the priority given, to map a character code to a Unicode value.
> ...

Reading that paragraph literally, it doesn't seem too unreasonable to use *different* methods for different charcodes.

Fixes 8229.
This commit is contained in:
Jonas Jenwald 2017-11-26 13:29:43 +01:00
parent ffbfc3c2a7
commit 61e19bee43
5 changed files with 21 additions and 3 deletions

View file

@ -53,6 +53,7 @@
!issue8061.pdf
!issue8088.pdf
!issue8125.pdf
!issue8229.pdf
!issue8372.pdf
!issue8424.pdf
!issue8480.pdf

BIN
test/pdfs/issue8229.pdf Normal file

Binary file not shown.

View file

@ -1438,6 +1438,13 @@
"link": false,
"type": "text"
},
{ "id": "issue8229",
"file": "pdfs/issue8229.pdf",
"md5": "a729f663782e87ebc1efad0755ebf6a5",
"rounds": 1,
"link": false,
"type": "text"
},
{ "id": "ShowText-ShadingPattern",
"file": "pdfs/ShowText-ShadingPattern.pdf",
"md5": "fe683725db037ffe19d390969610a652",