summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-11-09 16:53:51 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-11-09 19:22:18 +0000
commitbf64b4f1451896810b66fd6edf6175f0dd46ac44 (patch)
tree26da592c27b22f750dff3982dc1a0e012ca5f36f /xmlsecurity
parentf68b1541ea2f26a1137d4d20ceb23d036d0a00b7 (diff)
xmlsecurity PDF sign: compress the xref stream
This way it's a bit smaller for large files and our output is closer to what Acrobat produces. Change-Id: Ide5f7b58a74a9d6ad7d806814eb57cb6931023cc Reviewed-on: https://gerrit.libreoffice.org/30726 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/pdfio/pdfdocument.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index fa0d9cc99a4a..c73ee5d55ac9 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -738,7 +738,7 @@ bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificat
}
m_aEditBuffer.WriteUInt32AsString(nXRefStreamId);
- m_aEditBuffer.WriteCharPtr(" 0 obj\n<<");
+ m_aEditBuffer.WriteCharPtr(" 0 obj\n<</Filter/FlateDecode");
// ID.
auto pID = dynamic_cast<PDFArrayElement*>(m_pXRefStream->Lookup("ID"));
@@ -784,6 +784,18 @@ bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificat
// Length.
m_aEditBuffer.WriteCharPtr("/Length ");
+ {
+ ZCodec aZCodec;
+ aZCodec.BeginCompression();
+ aXRefStream.Seek(0);
+ SvMemoryStream aStream;
+ aZCodec.Compress(aXRefStream, aStream);
+ aZCodec.EndCompression();
+ aXRefStream.Seek(0);
+ aXRefStream.SetStreamSize(0);
+ aStream.Seek(0);
+ aXRefStream.WriteStream(aStream);
+ }
m_aEditBuffer.WriteUInt32AsString(aXRefStream.GetSize());
if (!m_aStartXRefs.empty())