From 8ce58f522e046ae3b1561d592ca7b3cd7c894731 Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Thu, 29 Jun 2017 13:40:22 -0400 Subject: Added FPDFAnnot_RemoveAnnot() Added an API for removing annotation and an embedder test for it. Bug=pdfium:737 Change-Id: I6f01625e8103078b83967a57a5c1a7a26bc0c70a Reviewed-on: https://pdfium-review.googlesource.com/7039 Commit-Queue: Jane Liu Reviewed-by: Lei Zhang --- fpdfsdk/fpdfannot.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'fpdfsdk/fpdfannot.cpp') diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp index 4a288b7df7..3d003d738e 100644 --- a/fpdfsdk/fpdfannot.cpp +++ b/fpdfsdk/fpdfannot.cpp @@ -201,6 +201,19 @@ DLLEXPORT void STDCALL FPDFPage_CloseAnnot(FPDF_ANNOTATION annot) { delete CPDFAnnotContextFromFPDFAnnotation(annot); } +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_RemoveAnnot(FPDF_PAGE page, int index) { + CPDF_Page* pPage = CPDFPageFromFPDFPage(page); + if (!pPage || !pPage->m_pFormDict || index < 0) + return false; + + CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); + if (!pAnnots || static_cast(index) >= pAnnots->GetCount()) + return false; + + pAnnots->RemoveAt(index); + return true; +} + DLLEXPORT FPDF_ANNOTATION_SUBTYPE STDCALL FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot) { if (!annot) -- cgit v1.2.3