Commit 9d4f52c01410c0be08635516675938cd27b41fed

Authored by Jay Berkenbilt
1 parent f13558dd

Clarify documentation on encrypted files

Explicitly state how QPDF handles empty passwords when writing files.
Apparently some libraries treat the empty string as the owner password
as an instruction to generate a random password.
Showing 1 changed file with 14 additions and 7 deletions
include/qpdf/QPDFWriter.hh
... ... @@ -219,13 +219,20 @@ class QPDFWriter
219 219 QPDF_DLL
220 220 void copyEncryptionParameters(QPDF&);
221 221  
222   - // Set up for encrypted output. Disables stream prefiltering and
223   - // content normalization. Note that setting R2 encryption
224   - // parameters sets the PDF version to at least 1.3, setting R3
225   - // encryption parameters pushes the PDF version number to at least
226   - // 1.4, setting R4 parameters pushes the version to at least 1.5,
227   - // or if AES is used, 1.6, and setting R5 or R6 parameters pushes
228   - // the version to at least 1.7 with extension level 3.
  222 + // Set up for encrypted output. User and owner password both must
  223 + // be specified. Either or both may be the empty string. Note
  224 + // that qpdf does not apply any special treatment to the empty
  225 + // string, which makes it possible to create encrypted files with
  226 + // empty owner passwords and non-empty user passwords or with the
  227 + // same password for both user and owner. Some PDF reading
  228 + // products don't handle such files very well. Enabling
  229 + // encryption disables stream prefiltering and content
  230 + // normalization. Note that setting R2 encryption parameters sets
  231 + // the PDF version to at least 1.3, setting R3 encryption
  232 + // parameters pushes the PDF version number to at least 1.4,
  233 + // setting R4 parameters pushes the version to at least 1.5, or if
  234 + // AES is used, 1.6, and setting R5 or R6 parameters pushes the
  235 + // version to at least 1.7 with extension level 3.
229 236 QPDF_DLL
230 237 void setR2EncryptionParameters(
231 238 char const* user_password, char const* owner_password,
... ...