mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Editor Plugin: Save modified document
This commit is contained in:
@@ -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);
|
||||
|
@@ -133,6 +133,7 @@ public:
|
||||
PDFObjectFactory& operator<<(const PDFDestination& destination);
|
||||
PDFObjectFactory& operator<<(PageRotation pageRotation);
|
||||
PDFObjectFactory& operator<<(PDFFormSubmitFlags flags);
|
||||
PDFObjectFactory& operator<<(PDFDictionary dictionary);
|
||||
|
||||
/// Treat containers - write them as array
|
||||
template<typename Container, typename ValueType = decltype(*std::begin(std::declval<Container>()))>
|
||||
@@ -343,6 +344,9 @@ public:
|
||||
/// if document being built was invalid.
|
||||
PDFDocument build();
|
||||
|
||||
/// Replaces all objects by references in the dictionary
|
||||
void replaceObjectsByReferences(PDFDictionary& dictionary);
|
||||
|
||||
/// If object is reference, the dereference attempt is performed
|
||||
/// and object is returned. If it is not a reference, then self
|
||||
/// is returned. If dereference attempt fails, then null object
|
||||
|
@@ -427,6 +427,8 @@ public:
|
||||
/// Removes null objects from dictionary
|
||||
void removeNullObjects();
|
||||
|
||||
bool isEmpty() const { return getCount() == 0; }
|
||||
|
||||
/// Optimizes the dictionary for memory consumption
|
||||
virtual void optimize() override;
|
||||
|
||||
|
@@ -778,6 +778,11 @@ void PDFEditedPageContentElementText::setItemsAsText(const QString& newItemsAsTe
|
||||
m_itemsAsText = newItemsAsText;
|
||||
}
|
||||
|
||||
PDFPageContentEditorContentStreamBuilder::PDFPageContentEditorContentStreamBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PDFPageContentEditorContentStreamBuilder::writeStateDifference(QTextStream& stream, const PDFPageContentProcessorState& state)
|
||||
{
|
||||
m_currentState.setState(state);
|
||||
@@ -1065,6 +1070,11 @@ void PDFPageContentEditorContentStreamBuilder::writeElement(const PDFEditedPageC
|
||||
stream << Qt::endl;
|
||||
}
|
||||
|
||||
const QByteArray& PDFPageContentEditorContentStreamBuilder::getOutputContent() const
|
||||
{
|
||||
return m_outputContent;
|
||||
}
|
||||
|
||||
void PDFPageContentEditorContentStreamBuilder::writePainterPath(QTextStream& stream,
|
||||
const QPainterPath& path,
|
||||
bool isStroking,
|
||||
@@ -1455,4 +1465,9 @@ void PDFPageContentEditorContentStreamBuilder::addError(const QString& error)
|
||||
m_errors << error;
|
||||
}
|
||||
|
||||
void PDFPageContentEditorContentStreamBuilder::setFontDictionary(const PDFDictionary& newFontDictionary)
|
||||
{
|
||||
m_fontDictionary = newFontDictionary;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
@@ -218,6 +218,15 @@ public:
|
||||
|
||||
const QByteArray& getOutputContent() const;
|
||||
|
||||
const PDFDictionary& getFontDictionary() const { return m_fontDictionary; }
|
||||
const PDFDictionary& getXObjectDictionary() const { return m_xobjectDictionary; }
|
||||
const PDFDictionary& getGraphicStateDictionary() const { return m_graphicStateDictionary; }
|
||||
|
||||
void setFontDictionary(const PDFDictionary& newFontDictionary);
|
||||
|
||||
const QStringList& getErrors() const { return m_errors; }
|
||||
void clearErrors() { m_errors.clear(); }
|
||||
|
||||
private:
|
||||
void writePainterPath(QTextStream& stream,
|
||||
const QPainterPath& path,
|
||||
|
Reference in New Issue
Block a user