Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BaseFont subset prefix generation deterministic #623

Closed
bsanchezb opened this issue Nov 24, 2021 · 0 comments · Fixed by #627
Closed

Make BaseFont subset prefix generation deterministic #623

bsanchezb opened this issue Nov 24, 2021 · 0 comments · Fixed by #627

Comments

@bsanchezb
Copy link
Contributor

Hello,

While trying to embed a font subset to a PDF, we have faced with an issue in OpenPdf, as it generates a new random name for a font subset each time a single PDF document is generated.

As in our signature creation tool, we need to execute the PDF generation twice, one for a ToBeSigned data generation and the second one for a final signed document generation, the generated PDF document shall be produced in a deterministic way.

The problem comes from a method BaseFont.createSubsetPrefix() generating a random prefix name for a font when a subset option is used. This makes the use of subsets impossible in our implementation, as the generated PDF and its digest respectively are always different.

Would it be possible to make the prefix computation deterministic somehow? For example by using org.bouncycastle.crypto.prng.FixedSecureRandom from BouncyCastle and the used glyphs within the provided subset as seed for pseudo random value generation.

Just for the information, there is no requirement in ISO 32000 to have the prefix random. It just shall be different for different subsets:

9.9.2 Font subsets

For a font subset, the PostScript name of the font, that is, the value of the font’s BaseFont entry and the
font descriptor’s FontName entry, shall begin with a tag followed by a plus sign (+) followed by the
PostScript name of the font from which the subset was created. The tag shall consist of exactly six
uppercase letters; the choice of letters is arbitrary, but different subsets of the same font in the same
PDF file shall have different tags.

Thank you!

Best regards,
Aleksandr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant