You are not logged in.
var
Pdf: TPdfDocumentGDI;
begin
Pdf := TPdfDocumentGDI.Create;
try
Pdf.UserPassword := 'view123'; // Password to open PDF
Pdf.OwnerPassword := 'edit456'; // Password to override restrictions
Pdf.EncryptPDF := True;
Pdf.EncryptionPermissions := [ppPrint, ppCopy]; // Permissions
Pdf.AddPage;
Pdf.VCLCanvas.TextOut(100, 100, 'Encrypted content');
Pdf.SaveToFile('encrypted.pdf');
finally
Pdf.Free;
end;
This part does not compile, why??
Pdf.UserPassword := 'view123'; // Password to open PDF
Pdf.OwnerPassword := 'edit456'; // Password to override restrictions
Pdf.EncryptPDF := True;
Pdf.EncryptionPermissions := [ppPrint, ppCopy]; // Permissions
Eric
Offline
This part does not compile, why??
That's because ChatGPT is NOT a programmer and if it doesn't know something... it just makes stuff up (which often doesn't work).
If you want encryption search this forum for TPdfEncryption and check out the examples as to how it's done correctly.
Offline