View Issue Details

IDProjectCategoryView StatusLast Update
0034072FPCPackagespublic2018-10-30 08:27
ReporterPetr-KAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0034072: fcl-pdf extension - added /ID into trailer
DescriptionRequired by PDF/A.
I implemented it closely to specification by MD5.
I hope that adding md5 dependency does not mind.
If it minds, I can reimplement it for example only by converting string s into hexa.
TagsNo tags attached.
Fixed in Revision39543
FPCOldBugId
FPCTarget
Attached Files
  • fppdf.patch (2,354 bytes)
    --- packages/fcl-pdf/src/fppdf.pp.1	2018-07-31 06:05:57.943858203 +0200
    +++ packages/fcl-pdf/src/fppdf.pp	2018-08-01 11:37:09.153354994 +0200
    @@ -272,6 +272,17 @@
         property    Value: AnsiString read FValue;
       end;
     
    +  { TPDFRawHexString }
    +
    +  TPDFRawHexString = class(TPDFDocumentObject)
    +  private
    +    FValue: String;
    +  protected
    +    procedure Write(const AStream: TStream); override;
    +  public
    +    constructor Create(Const ADocument : TPDFDocument; const AValue: String); overload;
    +    property    Value: String read FValue;
    +  end;
     
       TPDFUTF8String = class(TPDFAbstractString)
       private
    @@ -1006,6 +1017,7 @@
         function CreateContentsEntry(const APageNum: integer): integer;virtual;
         function CreateCatalogEntry: integer;virtual;
         procedure CreateInfoEntry;virtual;
    +    procedure CreateTrailerID;virtual;
         procedure CreatePreferencesEntry;virtual;
         function CreatePagesEntry(Parent: integer): integer;virtual;
         function CreatePageEntry(Parent, PageNum: integer): integer;virtual;
    @@ -1148,6 +1160,7 @@
     
     uses
       math,
    +  md5,
       fpttf;
     
     
    @@ -1327,6 +1340,19 @@
       Result := APixels / cDefaultDPI;
     end;
     
    +{ TPDFRawHexString }
    +
    +procedure TPDFRawHexString.Write(const AStream: TStream);
    +begin
    +  WriteString('<'+FValue+'>', AStream);
    +end;
    +
    +constructor TPDFRawHexString.Create(const ADocument: TPDFDocument; const AValue: String);
    +begin
    +  inherited Create(ADocument);
    +  FValue := AValue;
    +end;
    +
     { TPDFMatrix }
     
     function TPDFMatrix.Transform(APoint: TPDFCoord): TPDFCoord;
    @@ -4378,6 +4404,20 @@
       IDict.AddString('CreationDate',DateToPdfDate(Infos.CreationDate));
     end;
     
    +procedure TPDFDocument.CreateTrailerID;
    +var
    +  s: string;
    +  ID: TPDFArray;
    +begin
    +  s := DateToPdfDate(Now) + IntToStr(GLobalXRefCount) +
    +    Infos.Title + Infos.Author + Infos.ApplicationName + Infos.Producer + DateToPdfDate(Infos.CreationDate);
    +  s := MD5Print(MD5String(s));
    +  ID := CreateArray;
    +  ID.AddItem(TPDFRawHexString.Create(Self, s));
    +  ID.AddItem(TPDFRawHexString.Create(Self, s));
    +  Trailer.AddElement('ID', ID);
    +end;
    +
     procedure TPDFDocument.CreatePreferencesEntry;
     
     var
    @@ -4910,6 +4950,7 @@
       CreateTrailer;
       FCatalogue:=CreateCatalogEntry;
       CreateInfoEntry;
    +  CreateTrailerID;
       CreatePreferencesEntry;
       if (FontDirectory = '') then
         FontDirectory:=ExtractFilePath(ParamStr(0));
    
    fppdf.patch (2,354 bytes)

Activities

Petr-K

2018-08-01 11:44

reporter  

fppdf.patch (2,354 bytes)
--- packages/fcl-pdf/src/fppdf.pp.1	2018-07-31 06:05:57.943858203 +0200
+++ packages/fcl-pdf/src/fppdf.pp	2018-08-01 11:37:09.153354994 +0200
@@ -272,6 +272,17 @@
     property    Value: AnsiString read FValue;
   end;
 
+  { TPDFRawHexString }
+
+  TPDFRawHexString = class(TPDFDocumentObject)
+  private
+    FValue: String;
+  protected
+    procedure Write(const AStream: TStream); override;
+  public
+    constructor Create(Const ADocument : TPDFDocument; const AValue: String); overload;
+    property    Value: String read FValue;
+  end;
 
   TPDFUTF8String = class(TPDFAbstractString)
   private
@@ -1006,6 +1017,7 @@
     function CreateContentsEntry(const APageNum: integer): integer;virtual;
     function CreateCatalogEntry: integer;virtual;
     procedure CreateInfoEntry;virtual;
+    procedure CreateTrailerID;virtual;
     procedure CreatePreferencesEntry;virtual;
     function CreatePagesEntry(Parent: integer): integer;virtual;
     function CreatePageEntry(Parent, PageNum: integer): integer;virtual;
@@ -1148,6 +1160,7 @@
 
 uses
   math,
+  md5,
   fpttf;
 
 
@@ -1327,6 +1340,19 @@
   Result := APixels / cDefaultDPI;
 end;
 
+{ TPDFRawHexString }
+
+procedure TPDFRawHexString.Write(const AStream: TStream);
+begin
+  WriteString('<'+FValue+'>', AStream);
+end;
+
+constructor TPDFRawHexString.Create(const ADocument: TPDFDocument; const AValue: String);
+begin
+  inherited Create(ADocument);
+  FValue := AValue;
+end;
+
 { TPDFMatrix }
 
 function TPDFMatrix.Transform(APoint: TPDFCoord): TPDFCoord;
@@ -4378,6 +4404,20 @@
   IDict.AddString('CreationDate',DateToPdfDate(Infos.CreationDate));
 end;
 
+procedure TPDFDocument.CreateTrailerID;
+var
+  s: string;
+  ID: TPDFArray;
+begin
+  s := DateToPdfDate(Now) + IntToStr(GLobalXRefCount) +
+    Infos.Title + Infos.Author + Infos.ApplicationName + Infos.Producer + DateToPdfDate(Infos.CreationDate);
+  s := MD5Print(MD5String(s));
+  ID := CreateArray;
+  ID.AddItem(TPDFRawHexString.Create(Self, s));
+  ID.AddItem(TPDFRawHexString.Create(Self, s));
+  Trailer.AddElement('ID', ID);
+end;
+
 procedure TPDFDocument.CreatePreferencesEntry;
 
 var
@@ -4910,6 +4950,7 @@
   CreateTrailer;
   FCatalogue:=CreateCatalogEntry;
   CreateInfoEntry;
+  CreateTrailerID;
   CreatePreferencesEntry;
   if (FontDirectory = '') then
     FontDirectory:=ExtractFilePath(ParamStr(0));
fppdf.patch (2,354 bytes)

Michael Van Canneyt

2018-08-01 17:58

administrator   ~0109816

Adding MD5 dependency is OK.

Michael Van Canneyt

2018-08-02 07:55

administrator   ~0109824

Tested and applied the patch, thank you very much!

Issue History

Date Modified Username Field Change
2018-08-01 11:44 Petr-K New Issue
2018-08-01 11:44 Petr-K File Added: fppdf.patch
2018-08-01 17:57 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-08-01 17:57 Michael Van Canneyt Status new => assigned
2018-08-01 17:58 Michael Van Canneyt Note Added: 0109816
2018-08-02 07:55 Michael Van Canneyt Fixed in Revision => 39543
2018-08-02 07:55 Michael Van Canneyt Note Added: 0109824
2018-08-02 07:55 Michael Van Canneyt Status assigned => resolved
2018-08-02 07:55 Michael Van Canneyt Fixed in Version => 3.1.1
2018-08-02 07:55 Michael Van Canneyt Resolution open => fixed
2018-08-02 07:55 Michael Van Canneyt Target Version => 3.2.0
2018-10-30 08:27 Petr-K Status resolved => closed