chore: slight improvement of the encrypt feature to be more in line with others features

This commit is contained in:
Julien Neuhart
2025-05-28 15:21:41 +02:00
parent 99307befdd
commit ba944f9dc2
19 changed files with 318 additions and 797 deletions

View File

@@ -151,7 +151,6 @@ func (engine *PdfTk) Encrypt(ctx context.Context, logger *zap.Logger, inputPath,
return errors.New("user password cannot be empty")
}
// If owner password is not provided, use the user password as owner password
if ownerPassword == "" {
ownerPassword = userPassword
}
@@ -160,14 +159,8 @@ func (engine *PdfTk) Encrypt(ctx context.Context, logger *zap.Logger, inputPath,
args = append(args, inputPath)
args = append(args, "output", inputPath)
args = append(args, "encrypt_128bit")
if userPassword != "" {
args = append(args, "user_pw", userPassword)
}
if ownerPassword != "" {
args = append(args, "owner_pw", ownerPassword)
}
args = append(args, "user_pw", userPassword)
args = append(args, "owner_pw", ownerPassword)
cmd, err := gotenberg.CommandContext(ctx, logger, engine.binPath, args...)
if err != nil {