Hi, I'm a newbie to Aspose and I hope this is an easy issue to fix. My .NET solution will generate a text stamp on a pdf document for approvals. If the document is ever approved a second time, my text stamp needs removed and a new one generated in it's place. I don't have errors in my code or at runtime and the contentEditor.DeleteStampById(int) appears to run fine, but no results. Here is my code.
Aspose.Pdf.Facades.PdfContentEditor contentEditor = new Aspose.Pdf.Facades.PdfContentEditor();
contentEditor.BindPdf(li.File.OpenBinaryStream());
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(li.File.OpenBinaryStream());
//Count of pages on document
int iPageCount = pdfDocument.Pages.Count;
//Get all stamps in the document
Aspose.Pdf.Facades.StampInfo[] stampInfo = contentEditor.GetStamps(iPageCount);
//Loop through each stamp
for (int i = 0; i < stampInfo.Length; i++)
{
//Check to see if the ID = 999, if so delete the stamp.
if (stampInfo[i].StampId == 999)
{
contentEditor.DeleteStampById(stampInfo[i].StampId);
}
}
//Adjust for Easter Standard Time
DateTime dtServerTime = DateTime.Now;
DateTime dtEST = dtServerTime.Add(new TimeSpan(GetTimeZoneOffset(), 0, 0));
Aspose.Pdf.Facades.FormattedText txtFormatted = new Aspose.Pdf.Facades.FormattedText();
txtFormatted.AddNewLineText("Processed/Reviewed By:");
txtFormatted.AddNewLineText(web.CurrentUser + " " + dtEST);
TextStamp textStamp = new TextStamp(txtFormatted);
textStamp.Background = true;
textStamp.BottomMargin = 50;
textStamp.HorizontalAlignment = HorizontalAlignment.Right;
textStamp.VerticalAlignment = VerticalAlignment.Bottom;
textStamp.XIndent = 10;
textStamp.YIndent = 10;
textStamp.TextState.FontSize = 10.0F;
textStamp.Opacity = 100;
//Set ID of stamp
textStamp.setStampId(999);
pdfDocument.Pages[iPageCount].AddStamp(textStamp);
//Hold the bits of the PDF
MemoryStream pdfNewDocument = new MemoryStream();
//save output document
pdfDocument.Save(pdfNewDocument);