Encryption bugfixing (RC4)

This commit is contained in:
Jakub Melka
2021-05-30 15:37:06 +02:00
parent e3fecc0568
commit e001adc65b
11 changed files with 132 additions and 64 deletions

View File

@ -319,8 +319,18 @@ PDFOperationResult PDFDocumentWriter::write(QIODevice* device, const PDFDocument
// Jakub Melka: Adjust trailer dictionary, to be really dictionary, not a stream
PDFDictionary trailerDictionary = *document->getTrailerDictionary();
trailerDictionary.removeEntry("XRefStm");
PDFObject trailerDictionaryObject = PDFObject::createDictionary(std::make_shared<PDFDictionary>(qMove(trailerDictionary)));
PDFDictionary newTrailerDictionary;
for (const char* entry : { "Size", "Root", "Encrypt", "Info", "ID"})
{
PDFObject object = trailerDictionary.get(entry);
if (!object.isNull())
{
newTrailerDictionary.addEntry(PDFInplaceOrMemoryString(entry), qMove(object));
}
}
PDFObject trailerDictionaryObject = PDFObject::createDictionary(std::make_shared<PDFDictionary>(qMove(newTrailerDictionary)));
device->write("trailer");
writeCRLF(device);