From e8d3e372087e87139360104bff250747ae3a3367 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 31 Oct 2023 19:59:59 +0530 Subject: [PATCH] When saving PDF in PoDoFo dont collect garbage to avoid slowdowns with some PDF files See #2041745 (metadata in PDF very slow or gives errors) --- src/calibre/utils/podofo/doc.cpp | 4 ---- src/calibre/utils/podofo/global.h | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/calibre/utils/podofo/doc.cpp b/src/calibre/utils/podofo/doc.cpp index b174ea6523..648a90c1bb 100644 --- a/src/calibre/utils/podofo/doc.cpp +++ b/src/calibre/utils/podofo/doc.cpp @@ -6,12 +6,8 @@ */ #include "global.h" -#include #include #include -#include -#include -#include using namespace pdf; diff --git a/src/calibre/utils/podofo/global.h b/src/calibre/utils/podofo/global.h index b1b1e699b5..1fcb0f05e2 100644 --- a/src/calibre/utils/podofo/global.h +++ b/src/calibre/utils/podofo/global.h @@ -13,7 +13,6 @@ #define USING_SHARED_PODOFO #include #include -#include using namespace PoDoFo; using namespace std::literals; @@ -130,9 +129,9 @@ object_as_reference(const PdfObject *o) { return o->IsReference() ? o->GetReference() : o->GetIndirectReference(); } -// Needed to avoid PoDoFo clobbering the /Info and XMP metadata with its own nonsense -// rename to NoMetadataUdate after https://github.com/podofo/podofo/commit/96689eb6e45b71eae1577ecb2d4a796c52e9a813 -static const PdfSaveOptions save_options = PdfSaveOptions::NoModifyDateUpdate; +// NoMetadataUpdate needed to avoid PoDoFo clobbering the /Info and XMP metadata with its own nonsense +// NoCollectGarbage needed to avoid slowdowns on writing, see https://github.com/podofo/podofo/issues/99#issuecomment-1787239479 +static const PdfSaveOptions save_options = PdfSaveOptions::NoMetadataUpdate | PdfSaveOptions::NoCollectGarbage; class PdfReferenceHasher { public: