Skip to content

Commit

Permalink
Fix corrupting pdf background when saving
Browse files Browse the repository at this point in the history
When opening a xournal with pdf background and saving it again, the pdf got corrupted.
  • Loading branch information
taukakao authored and Technius committed Oct 16, 2022
1 parent 0dce580 commit 4b23e88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/control/xojfile/SaveHandler.cpp
@@ -1,6 +1,7 @@
#include "SaveHandler.h"

#include <cinttypes>
#include <filesystem> // for exists

#include <config.h>

Expand Down Expand Up @@ -233,7 +234,9 @@ void SaveHandler::visitPage(XmlNode* root, PageRef p, Document* doc, int id) {
background->setAttrib("filename", "bg.pdf");

GError* error = nullptr;
doc->getPdfDocument().save(filepath, &error);
if (!exists(filepath)) {
doc->getPdfDocument().save(filepath, &error);
}

if (error) {
if (!this->errorMessage.empty()) {
Expand Down

0 comments on commit 4b23e88

Please sign in to comment.