<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Sign PDF with digital signature"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=99416#c19">Comment # 19</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Sign PDF with digital signature"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=99416">bug 99416</a>
              from <span class="vcard"><a class="email" href="mailto:ajohnson@redneon.com" title="Adrian Johnson <ajohnson@redneon.com>"> <span class="fn">Adrian Johnson</span></a>
</span></b>
        <pre>(In reply to Hans-Ulrich Jüttner from <a href="show_bug.cgi?id=99416#c18">comment #18</a>)
<span class="quote">> > After saving the PDF, open the saved PDF in a new PDFDoc object.
> > 

> How is this supposed to be done? The user of the library calls the method
> sign() from the Qt5 interface or signDocument() from poppler/Form.h via some
> other interface. Are you saying that the doc member of type PDFDoc* within
> the
> FormFieldSignature object should be replaced by a new one? I think that can't
> work because there are other references to the PDFDoc object in the library
> outside the FormFieldSignature object.</span >

Create a temporary PDFDoc* variable for the purpose of opening the PDF and
getting the size and offset of the sig object. You can have more than one
PDFDoc object at the same time.

<span class="quote">> The user of the library opens the PDF document, than perhaps makes some
> changes
> and finally calls the method FormFieldSignature::sign() from the Qt5
> interface.
> Afterwards he saves the changed document with the PDFConverter class of the
> Qt5 interface. If he makes other changes to the document after calling sign()
> but before saving, the signature will of course be no longer valid.</span >

Well yes changing the document after adding a signature will break the
signature. I'm not seeing the problem here. Maybe warn the user if he tries to
change a signed document.

<span class="quote">> The problem is not saving a few bytes but specifying the final byte offsets.
> If a byte offset changes the number of digits may vary at least between 6 and
> 10. If for example the total length of the document increases, the byte range
> object might have to increase in size too because an additional digit is used
> for that length. Thus in turn the start offset of the signature is shifted by
> one byte because the byte range object is located in front of the signature.</span >

When saving, set each offset to 9999999999, then search for and overwrite the
9's with the correct offsets.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>