Editor Plugin: Save modified document

This commit is contained in:
Jakub Melka
2024-05-26 20:12:44 +02:00
parent 17b275c8b1
commit d83689cddb
9 changed files with 203 additions and 0 deletions

View File

@ -285,6 +285,12 @@ PDFObjectFactory& PDFObjectFactory::operator<<(AnnotationBorderStyle style)
return *this;
}
PDFObjectFactory& PDFObjectFactory::operator<<(PDFDictionary dictionary)
{
*this << PDFObject::createDictionary(std::make_shared<pdf::PDFDictionary>(std::move(dictionary)));
return *this;
}
PDFObjectFactory& PDFObjectFactory::operator<<(const QDateTime& dateTime)
{
addObject(PDFObject::createString(PDFEncoding::convertDateTimeToString(dateTime)));
@ -708,6 +714,19 @@ PDFDocument PDFDocumentBuilder::build()
return PDFDocument(PDFObjectStorage(m_storage), m_version, QByteArray());
}
void PDFDocumentBuilder::replaceObjectsByReferences(PDFDictionary& dictionary)
{
for (size_t i = 0; i < dictionary.getCount(); ++i)
{
const PDFObject& object = dictionary.getValue(i);
if (!object.isReference())
{
auto key = dictionary.getKey(i);
dictionary.setEntry(key, PDFObject::createReference(addObject(object)));
}
}
}
QByteArray PDFDocumentBuilder::getDecodedStream(const PDFStream* stream) const
{
return m_storage.getDecodedStream(stream);