You are not logged in.
I have to generate a encrypted pdf with user limitations, this works generally fine. There is only one issue regarding the TPdfDocumentGDI.Info properties like Author, Subject and Title. These properties are not readable any more by Adobe Acrobat in case of activated encryption. I searched the forum and nobody besides me seems to face this issue. Maybe someone can tell me what I am doing wrong.
The relevant code is:
function GetPdfDoc(Subject:string; Title:string; FileName:string=''):TPdfDocumentGDI;
begin
if CfgSettings.PdfPassword = '' then Result := TPdfDocumentGDI.Create // no encryption
else Result := TPdfDocumentGDI.Create(false,0,false,TPdfEncryption.New(elRC4_128,'',CfgSettings.PdfPassword,PDF_PERMISSION_NOCOPY));
Result.DefaultPaperSize := psA4;
Result.ScreenLogPixels := ActScreenLogPixels;
Result.EmbeddedTTF := true;
Result.EmbeddedTTFIgnore.Text:= My_DEFAULT_FONTS;
Result.EmbeddedWholeTTF := true;
Result.Info.Author := CfgSettings.GetUserFullName; // Get user name
Result.Info.CreationDate := Now;
Result.Info.Creator := CreatorApp; // name of App
Result.Info.Subject := Subject;
Result.Info.Title := Title;
if Filename <> '' then Result.Info.Title := Result.Info.Title+' '+FileName;
end;
If encryption is turned on, the properties shown by Adobe Acrobat change from readable strings to typical RC4-coded strings:
Title: 'Ł\ ²¾'
Author: '>3“ ñb ˛3¨°F já'
Subject: 'yRÈú`œ–çJ'
The question is: Is there a chance to encrypt the pdf in a way that document properties remain readable? Does someone know a solution or workaround for this?
Thanks for any help.
Wolfgang
Offline
If encryption is turned on, the properties shown by Adobe Acrobat change from readable strings to typical RC4-coded strings:
Title: 'Ł\ ²¾'
Author: '>3“ ñb ˛3¨°F já'
Subject: 'yRÈú`œ–çJ'
I am facing the same problem:
If encryption is activated, the document properties contain garbage. This was not the case in older versions of SynPDF, but I could not find out which revision introduced this problem.
Achim
Offline
We found out that in order to fix this problem, we can simply comment the following two lines in procedure TPdfEncryptionRC4MD5.EncodeBuffer :
// if (fDoc.fCurrentObjectNumber<>fLastObjectNumber) or
// (fDoc.fCurrentGenerationNumber<>fLastGenerationNumber) then
We are not sure if this is a valid fix. What do you think ?
Offline
This is issue https://github.com/synopse/SynPDF/issues/32
I tried to fix it with https://github.com/synopse/mORMot/commi … 5dc4d9566c
Feedback is welcome.
Offline
Hi ab,
This seems to have fixed the problem for us. Thank you!
Offline