Loading widgets

This commit is contained in:
Jakub Melka
2020-12-22 18:29:40 +01:00
parent fd902ac525
commit 96ae91b36d
11 changed files with 348 additions and 15 deletions

View File

@ -1101,6 +1101,35 @@ PDFObjectReference PDFDocumentBuilder::getCatalogReference() const
return PDFObjectReference();
}
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());
}
void PDFDocumentBuilder::updateDocumentInfo(PDFObject info)
{
PDFObjectReference infoReference = getDocumentInfo();