[poppler] There is a flaw with poppler that needs to be fixed. Deleted annotations are not actually deleted. I require assistance in fixing this.

Zeke Williams lakeleaf8 at gmail.com
Fri Sep 23 13:19:48 UTC 2022


I require assistance as I am not a very proficient C++ programmer with
this issue with poppler. What happens with poppler is that the portion
of the PDF document that shows the annotation is deleted when you
delete an annotation in such as okular or evince, but the actual
contents is in a separate part of the document and that doesn't get
deleted. Meaning in other words, it's still there. That is a privacy
violation that should be fixed. I believe this is the part of poppler
that removes the annotation:

bool Annots::removeAnnot(Annot *annot)
{
    auto idx = std::find(annots.begin(), annots.end(), annot);

    if (idx == annots.end()) {
        return false;
    } else {
        annot->decRefCnt();
        annots.erase(idx);
        return true;
    }
}

And from another PDF reader (PDF4QT) here is how it removes them:

void PDFDocumentBuilder::removeAnnotation(PDFObjectReference page,
PDFObjectReference annotation)
{
    PDFDocumentDataLoaderDecorator loader(&m_storage);

    if (const PDFDictionary* pageDictionary =
m_storage.getDictionaryFromObject(m_storage.getObjectByReference(page)))
    {
        std::vector<PDFObjectReference> annots =
loader.readReferenceArrayFromDictionary(pageDictionary, "Annots");
        annots.erase(std::remove(annots.begin(), annots.end(),
annotation), annots.end());

        PDFObjectFactory factory;
        factory.beginDictionary();
        factory.beginDictionaryItem("Annots");
        if (!annots.empty())
        {
            factory << annots;
        }
        else
        {
            factory << PDFObject();
        }
        factory.endDictionaryItem();
        factory.endDictionary();

        mergeTo(page, factory.takeObject());
    }

    setObject(annotation, PDFObject());
}

PDF4QT can be found here: https://github.com/JakubMelka/PDF4QT

What can we do to solve this? I think we should mimic how PDF4QT does
it. What do you think?


More information about the poppler mailing list