I've been playing around more since getting the stamping process to work for the most part. Now I am trying to delete all annotations from a PDF. I have tried it multiple ways as shown below:
public void ClearStamps()
{
IList<PdfAnnotation> annotList = pdfDoc.GetFirstPage().GetAnnotations();
int listCount = annotList.Count;
for (int i = 0; i < listCount; i++)
{
annotList.RemoveAt(i);
}
pdfDoc.Close();
if (Overwrite)
{
File.Delete(pdfFilePath);
File.Move(pdfFileDest, pdfFilePath);
}
}
OR
IList<PdfAnnotation> annotList = pdfDoc.GetFirstPage().GetAnnotations();
int listCount = annotList.Count;
for (int i = 0; i < listCount; i++)
{
annotList[i].Remove(PdfName.Annots);
}
pdfDoc.Close();
The resulting PDFs still remain intact after the operation above.
I also tried cycling through all the PdfName objects that resemble annotations (Annot, Annots, Annotation, etc.)
Is the method I am using to acquire the annotations incorrect? That is exactly how I acquired stamp properties for my stamp operation.
Additionally, when it comes to annotation manipulation, I can't seem to find any method that resembles the Flattening bool from iText5 - the closest I can get was setting the annotation flags to LOCKED...not the most ideal way to flatten.