smalot / pdfparser

PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.
GNU Lesser General Public License v3.0
2.3k stars 534 forks source link

Fix for two bugs related to Unicode translation support by Font objects #667

Closed unixnut closed 4 months ago

unixnut commented 5 months ago

Symptom was that some documents' contents was rendering as a bunch of control characters. These are the untranslated strings. This was happening because for two different reasons, these strings weren't being translated \Smalot\PdfParser\Font::decodeContent() in some circumstances.

First fix is to \Smalot\PdfParser\Font::loadTranslateTable():

Second fix is for documents that attach their Font objects to the Pages object instead of each Page object:

Type of pull request

About

Checklist for code / configuration changes

In case you changed the code/configuration, please read each of the following checkboxes as they contain valuable information:

GreyWyvern commented 5 months ago

I'm on vacation atm, but I can take a look at this on Monday. 👍

GreyWyvern commented 5 months ago
  • Your code is about decryption and encryption, but in the title its about Unicode translation. Please elaborate on that a bit.

After a first pass of the code, this is what I'd like to know as well. I feel like for this many lines, the description as to what this PR does needs to be much much longer! :D What's the purpose of this encryption/decryption code? Does it supercede the previous PR #653?

I will keep studying it.

k00ni commented 5 months ago

Please merge in master branch, to get rid of these coding style issues.

unixnut commented 5 months ago

@k00ni @GreyWyvern my mistake, I forgot GitHub consumes all commits on a branch for a PR.

This PR is supposed to be for the first commit only

k00ni commented 5 months ago

@k00ni @GreyWyvern my mistake, I forgot GitHub consumes all commits on a branch for a PR.

This PR is supposed to be for the first commit only

Proceed as you see fit. I assume either close this one and create another PR with your changes or simply remove all additional changes in this PR and force push in order to update it.

GreyWyvern commented 4 months ago

I think I would probably cancel this PR and start a clean one, but that's just me. :)

k00ni commented 4 months ago

Please open new PRs with smaller sets of code changes. Thanks.