<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#c20">Comment # 20</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:huj@froreich-bioscientia.de" title="Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>"> <span class="fn">Hans-Ulrich Jüttner</span></a>
</span></b>
<pre>(In reply to Adrian Johnson from <a href="show_bug.cgi?id=99416#c19">comment #19</a>)
<span class="quote">> (In reply to Hans-Ulrich Jüttner from <a href="show_bug.cgi?id=99416#c18">comment #18</a>)
> > > 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.
>
> 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 >
Sorry, I do not understand what a temporary PDFDoc object should help.
<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.
>
> 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.
>
> > 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.
>
> When saving, set each offset to 9999999999, then search for and overwrite
> the 9's with the correct offsets.</span >
That wouldn't help. The byte range object would shrink when these values later
are replaced by the correct smaller values. If you mean these values should be
overwritten on disk that would also be no solution as this is only a temporary
file and the file written later by the user would differ from it by some
missing blanks that have overwritten your 9's.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>