I tried going at it as annotations.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@convertDIR.ToString() + inFileName);
String watermarkText = theMark.ToString();
foreach (Aspose.Pdf.Page page in doc.Pages)
{
foreach (Annotation annot in page.Annotations)
{
page.Annotations.Remove(annot);
}
}
This is successful at removing the Textboxes we add as part of our stamping process, but no luck with the watermark
This code WORKS when we have the underlying WORD document - But in most cases, we only have the PDF stored or available, since that is what we publish to the investigators. Tried to use this logic against PDFs with no luck
Aspose.Words.Document doc = new Aspose.Words.Document(@convertDIR.ToString() + inFileName);
String watermarkText = theMark.ToString();
foreach (Aspose.Words.HeaderFooter hf in doc.GetChildNodes(NodeType.HeaderFooter, true))
{
Console.WriteLine(hf.HeaderFooterType);
Console.WriteLine(hf.IsHeader);
foreach (Aspose.Words.Drawing.Shape shape in hf.GetChildNodes(NodeType.Shape, true))
{
Console.WriteLine(shape.GetText());
string myText = shape.GetText();
Console.WriteLine(shape.Name);
Console.WriteLine(shape.TextPath.Text);
if (shape.Name.Contains("Not For Subject Use") || shape.TextPath.Text.Contains(watermarkText) || shape.GetText().Contains(watermarkText) || shape.TextPath.Text.ToLower().Contains(watermarkText.ToLower()))
{
shape.Remove();
}
}
}
Similarly tried Text Fragments to at least loop through in debug and see if I can see the item in the collection… came back 0 object size
Aspose.Pdf.Text.TextFragmentAbsorber TFA = new Aspose.Pdf.Text.TextFragmentAbsorber("Closed \r\nto\r\nAccrual");
doc.Pages[1].Accept(TFA);
TextFragmentCollection TFC = TFA.TextFragments;
foreach(TextFragment TF in TFC)
{
TF.Text = "";
}
Tried Stamps
Aspose.Pdf.Facades.PdfContentEditor contentEditor = new Aspose.Pdf.Facades.PdfContentEditor();
contentEditor.BindPdf(doc);
Aspose.Pdf.Facades.StampInfo[] stampInfo = contentEditor.GetStamps(1);
for (int i = 0; i < stampInfo.Length; i++)
{
}
And in the above, was just trying to see if it gave me a collectioon and then I could see the collection in debug as how best to identify, but came back with size of 0