Hi,
Hi Jak,
Thanks for contacting support.
I have tested the scenario using Aspose.Pdf for .NET 9.3.0 and as per my observations, the stamp is properly being removed using its ID. For testing purposes, I have used the following code snippet to add Text Stamp to PDF file.
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();
pdfDocument.Pages.Add();
DateTime dtServerTime = DateTime.Now;
DateTime dtEST = DateTime.Now;
Aspose.Pdf.Facades.FormattedText txtFormatted = new Aspose.Pdf.Facades.FormattedText();
txtFormatted.AddNewLineText("Processed/Reviewed By:");
txtFormatted.AddNewLineText(dtEST.ToString());
TextStamp textStamp = new TextStamp(txtFormatted);
textStamp.Background = true;
textStamp.BottomMargin = 50;
textStamp.HorizontalAlignment = Aspose.Pdf.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[1].AddStamp(textStamp);
pdfDocument.Save("c:\\pdftest\\Test_output2.pdf");
Then I have used the following code to remove the stamp and its properly being removed.
//load source document
Aspose.Pdf.Facades.PdfContentEditor contentEditor = new Aspose.Pdf.Facades.PdfContentEditor();
contentEditor.BindPdf("c:\\pdftest\\Test_output2.pdf");
//remove stamp by Id (without stamps iterating)
contentEditor.DeleteStampByIds(new int[] { 999 });
//save result into intermediate file
//(may be stored into memory stream to don't deal with temporary flles)
contentEditor.Save("c:/pdftest/Stamp_Removed.pdf");
In case you still face any problem, please share the resource PDF document and ID of Stamp so that we can test the scenario at our end. We are sorry for your inconvenience.
Hi Nayyer,
Hi Nayyer,
jak893:
To remove the stamp:
PdfContentEditor contentEditor = new PdfContentEditor(); contentEditor.BindPdf(path); contentEditor.DeleteStampById(11235813); contentEditor.Save(@"C:\temp\test.pdf");
Ideally, as well, I’d like to avoid saving to a new file and would instead like to replace ‘C:\temp\test.pdf’ with ‘path’ so the original file is just resaved but with the stamps removed.
Hi Jak,
Thanks for sharing the details.
I have again tested the scenario using Aspose.Pdf for .NET 9.3.0 in Visual Studio 2012 application where I have set the target platform of application as .NET Framework 4.0, running over Windows 7 (x64) and as per my observations, the Stamp object is properly being removed from PDF file. I have used the same code snippet to add stamp object, as you have stated in your earlier post.
Now concerning your other requirement of removing the stamp and saving the output in the same file, please try using the following code snippet:
// load source PDF file in Document object
Document doc = new Document(new FileStream("c:/pdftest/WithStamp
- Copy.pdf", FileMode.OpenOrCreate));
PdfContentEditor contentEditor = new PdfContentEditor();
// bind Doccument object to Content Editor
contentEditor.BindPdf(doc);
contentEditor.DeleteStampById(11235813);
// save the updated Document object to save the file (source/input)
doc.Save();
Can you please share some details regarding your working environment which can help us in replicating this issue at our end? We are sorry for this inconvenience.
jak893: After some more digging around, I’ve gotten to the root of the issue. It seems that even though another developer has called the SetLicense method, this has only applied to for the Aspose Words module of our Total license and makes sense that when I try and manipulate the PDF, the software thinks it’s running in a trial state.
Is there no way that I can call a global license method, this forum post would seem to suggest it’s not How to apply license for Aspose.Total for .Net, but it seems a little convoluted to have to call the SetLicense method for every module when a Total license has been purchased?
Hi Jak,
Every API under Aspose.Total umbrella has its own implementation and separate Document Object Model and they require individual license initialization. As you are using Aspose.Words for .NET and Aspose.Pdf for .NET in single application/solution, so you need to individually call setLicense method for both API’s.
[C#]
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("E:\\Aspose.Total.lic");
Aspose.Words.License wordlic = new Aspose.Words.License();
wordlic.SetLicense("e:\\Aspose.total.lic");