use setDeterministicID() from qpdf to produce bit-by-bit identical output without dropping the /ID #400
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We want to be able to create PDF files that are bit-by-bit identical if they share the same content. By default, the
ID
metadata will always differ because qpdf usesQUtil::get_current_time()
as part of the values it hashes. Setting theID
metadata to a static value is a bad idea because it would not make the file in question uniquely identifiable anymore according to PDF 1.7 reference section 10.3 "File Identifiers".Luckily for us, qpdf offers the
setDeterministicID()
function which avoids using the current time and the filename as input for the MD5 hash computation. This pull request exposes this functionality in pikepdf.Fixes: https://gitlab.mister-muffin.de/josch/img2pdf/issues/150