#1 2020-07-10 22:03:08

Wolfgang Haefele
Member
Registered: 2020-07-10
Posts: 1

SynPDF Encryption makes Document Information unreadable

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

#2 2020-11-10 08:15:11

kalwados
Member
Registered: 2011-04-18
Posts: 15

Re: SynPDF Encryption makes Document Information unreadable

Wolfgang Haefele wrote:

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

#3 2021-02-04 14:20:21

IBE Software
Member
Registered: 2020-12-29
Posts: 5

Re: SynPDF Encryption makes Document Information unreadable

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

#4 2021-02-04 16:46:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: SynPDF Encryption makes Document Information unreadable

Offline

#5 2021-02-05 10:40:37

IBE Software
Member
Registered: 2020-12-29
Posts: 5

Re: SynPDF Encryption makes Document Information unreadable

Hi ab,
This seems to have fixed the problem for us. Thank you!

Offline

Board footer

Powered by FluxBB