node-signpdf icon indicating copy to clipboard operation
node-signpdf copied to clipboard

Missing or empty ID in the document trailer

Open kzolti opened this issue 2 years ago • 1 comments

After signing, the new trailer does not contain the ID fields. verapdf output:

<details passedRules="144" failedRules="1" passedChecks="6295" failedChecks="1">
  <rule specification="ISO 19005-3:2012" clause="6.1.3" testNumber="1" status="failed" failedChecks="1">
    <description>The file trailer dictionary shall contain the ID keyword whose value shall be File Identifiers as defined in ISO 32000-1:2008, 14.4</description>
    <object>CosDocument</object>
    <test>lastID != null &amp;&amp; lastID.length() &gt; 0</test>
    <check status="failed">
      <context>root</context>
      <errorMessage>Missing or empty ID in the document trailer</errorMessage>
    </check>
  </rule>
</details>

I can eliminate the error if here: https://github.com/vbuch/node-signpdf/blob/develop/packages/placeholder-plain/src/createBufferTrailer.js I add static two ids;

return Buffer.concat([
    Buffer.from('xref\n'),
    Buffer.from(`${info.xref.startingIndex} 1\n`),
    Buffer.from(rows.join('\n')),
    Buffer.from('\ntrailer\n'),
    Buffer.from('<<\n'),
    Buffer.from(`/Size ${info.xref.maxIndex + 1}\n`),
    Buffer.from(`/Root ${info.rootRef}\n`),
    Buffer.from(info.infoRef ? `/Info ${info.infoRef}\n` : ''),
    Buffer.from(`/Prev ${info.xRefPosition}\n`),
    Buffer.from('/ID [<2A75465A48C679B420E97AFCA186B72A> <65DAA54B261896AB2FAC8B53976D9DFD>]\n>>\n'),
    Buffer.from('startxref\n'),
    Buffer.from(`${pdf.length}\n`),
    Buffer.from('%%EOF'),
]);

I already realized that the first ID should be the second ID from the previous trailer, but I didn't get any further.

The pdf signed in this way will already be valid.

kzolti avatar Sep 08 '24 17:09 kzolti