DocPage Organizer: Save assembled files

This commit is contained in:
Jakub Melka
2021-07-25 15:12:16 +02:00
parent b38bbf8468
commit 229234fc15
6 changed files with 70 additions and 7 deletions

View File

@ -173,6 +173,14 @@ void PDFWriteObjectVisitor::visitReference(const PDFObjectReference reference)
PDFOperationResult PDFDocumentWriter::write(const QString& fileName, const PDFDocument* document, bool safeWrite)
{
Q_ASSERT(document);
const PDFObjectStorage& storage = document->getStorage();
if (!storage.getSecurityHandler()->isEncryptionAllowed())
{
return tr("Writing of encrypted documents is not supported.");
}
if (safeWrite)
{
QSaveFile file(fileName);
@ -204,6 +212,13 @@ PDFOperationResult PDFDocumentWriter::write(const QString& fileName, const PDFDo
{
PDFOperationResult result = write(&file, document);
file.close();
if (!result)
{
// If some error occured, then remove invalid file
file.remove();
}
return result;
}
else