Bug 104815 - Signing of compressed PDF does not work
Summary: Signing of compressed PDF does not work
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
(earliest affected)
Hardware: All All
: medium normal
Assignee: Not Assigned
: 120892 (view as bug list)
Depends on:
Blocks: Digital-Signatures
  Show dependency treegraph
Reported: 2016-12-20 16:22 UTC by Martin Pietsch
Modified: 2020-06-05 07:38 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:

PDF files which will not function (288.83 KB, application/x-gzip)
2016-12-20 16:22 UTC, Martin Pietsch
simple example document where signing succeeds/fails (55.76 KB, application/zip)
2018-10-26 10:26 UTC, Ansgar Burchardt

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Pietsch 2016-12-20 16:22:46 UTC
Created attachment 129812 [details]
PDF files which will not function

Dear LibreOffice-Team,

the function to sign an existing PDF is a very good feature and I tried it with different PDF-files. The result has shown for me that the signing-procedure only function with PDF's which was created by LibreOffice. With other PDF I can select a signature but this will not added to the PDF and the signature list of the main signing dialog remained empty. Futhermore neither an error, warning nor other information is displayed. The only thing that happens, that the PDF is damanaged after this action.

You find an example PDFs, which will not function, before and after the signing process in the attachment.

What is the reason? Am I doing something wrong?

Thank you in advance for your effort.

Best regards,
Comment 1 Cor Nouws 2016-12-20 17:26:52 UTC Comment hidden (obsolete)
Comment 2 Ansgar Burchardt 2017-01-03 12:58:21 UTC
I can reproduce this with LibreOffice 5.3.0~rc1 (from Debian): signing the provided PDF files doesn't work and trying to do so produces a PDF file only including page 2 (and missing page 1).

As a workaround, opening the PDF and exporting it again allows to sign the file (then also via the "Sign existing PDF" option). However this should lose all signatures already present.

My suspicion is that this is related to the PDF version: the provided `test_before.pdf` is PDF-1.6; the files I could sign were PDF-1.4 or before.  This blog post suggests that it should work with newer PDF versions as well: http://vmiklos.hu/blog/pdf-sign.html, but maybe there are still some bugs in this new feature?

[ Added vmiklos to the CC list ]
Comment 3 QA Administrators 2017-07-27 12:06:48 UTC Comment hidden (obsolete)
Comment 4 Cor Nouws 2017-08-11 13:03:40 UTC
I confirm the problem in Version:
Build ID: 368b583b992f2e9cad46c2362c9529a07c36d7a9
CPU threads: 4; OS: Linux 4.10; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-08-10_02:55:46
Locale: nl-NL (nl_NL.UTF-8); Calc: group

and in on Win 10-64 (6.19)
Comment 5 Cor Nouws 2017-08-11 13:44:39 UTC
when trying to sign the PDF file from attachment 129812 [details], I do
 - select a certificate in the dialog Select Certificate
 - click OK
 > but then do not see the signature in the dialog Digital Signatures

(After closing and reopening the PDF for signing, the certificate is shown)
Comment 6 Cor Nouws 2017-08-11 13:55:57 UTC Comment hidden (no-value)
Comment 7 Juan Jose Pablos 2018-10-07 23:48:19 UTC
Maybe is a problem with that file.

Trying to validate your document using this online test. fail

But, if you export using libre office. this resulted file. passed the test.
Comment 8 Ansgar Burchardt 2018-10-26 10:26:34 UTC
Created attachment 146029 [details]
simple example document where signing succeeds/fails

I've attached simpler PDF documents with just the world "Hallo." that show the documented problem.  The pdfTeX source is also included.

I can sign pdf15uncompressed.pdf (which sets '\pdfobjcompresslevel=0') without problems.  The signature is shown as valid by libreoffice-writer.

Signing pdf15compressed.pdf (which uses the default \pdfobjcompresslevel setting) fails and produces an invalid PDF (that cannot be opened using either evince or libreoffice-writer).

I tried with libreoffice-writer 1:6.1.3~rc1-1 and 1:6.2.0~alpha1-1 (from Debian)
Comment 9 Timur 2018-10-26 13:05:51 UTC
Ansgar, if you are right, than we should update the title with "compressed PDF".
Your PDF's are version 1.5. 
Although you already found that it should work with newer PDF versions, can you please try to create version 1.6, to be sure?

I tried to find a method to test whether PDF is compressed, only hint is to use: 
strings your.pdf | grep /Filter
But I don't find it reliable.
Comment 10 Ansgar Burchardt 2018-10-26 13:28:43 UTC
Timur, I tried changing \pdfminorversion=5 to \pdfminorversion=6.  This shows the same problems with signing the uncompressed version.

The PDF 1.5/1.6 files generated this way by pdfTeX are almost identical.  The only difference are version number, timestamps and some ID:


-/CreationDate (D:20181026151605+02'00')
-/ModDate (D:20181026151605+02'00')
+/CreationDate (D:20181026151606+02'00')
+/ModDate (D:20181026151606+02'00')

-/ID [<85B2B94E82913D769D6C5843FF158106> <85B2B94E82913D769D6C5843FF158106>]
+/ID [<3183843648EC5FDFF762CA8F3B1A7532> <3183843648EC5FDFF762CA8F3B1A7532>]

I don't know anything about the PDF file format so cannot say how to identify files using object compression.  I just found the "\pdfobjcompresslevel=0" option when trying to generate a PDF Libreoffice could sign earlier this month.
Comment 11 Timur 2018-11-05 09:56:16 UTC
*** Bug 120892 has been marked as a duplicate of this bug. ***
Comment 12 Timur 2020-06-05 07:37:33 UTC
Possible example attachment 161609 [details].