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

use setDeterministicID() from qpdf to produce bit-by-bit identical output without dropping the /ID #400

Merged
merged 1 commit into from Oct 4, 2022

Conversation

josch
Copy link
Contributor

@josch josch commented Oct 2, 2022

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 uses QUtil::get_current_time() as part of the values it hashes. Setting the ID 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

@codecov
Copy link

codecov bot commented Oct 2, 2022

Codecov Report

Base: 97.02% // Head: 97.02% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (60cb1bb) compared to base (7f324b5).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #400   +/-   ##
=======================================
  Coverage   97.02%   97.02%           
=======================================
  Files          46       46           
  Lines        4234     4237    +3     
=======================================
+ Hits         4108     4111    +3     
  Misses        126      126           
Impacted Files Coverage Δ
src/pikepdf/_methods.py 99.01% <ø> (ø)
src/qpdf/qpdf.cpp 98.78% <100.00%> (+<0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jbarlow83 jbarlow83 merged commit 663fa0c into pikepdf:master Oct 4, 2022
@jbarlow83
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants