Removing Watermark added as Stamp

Is it still possible to delete stamps by ID since Aspose.Pdf.Kit was merged with Aspose.Pdf?

The link to the article is broken.

I see that the Aspose.Pdf.Facades.Stamp class has a StampId member, but I can’t see a way to retrieve or delete existing stamps.

Thanks

Hi Reuben,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

You can use PdfContentEditor.DeleteStampById Method of Aspose.Pdf.Facades namespace to delete the stamps using stampid. There are following two methods which you can use:

Delete stamp by ID from all pages of the document.

public void DeleteStampById(int);</o:p>

Deletes stamp on the specified page by stamp ID.

public void DeleteStampById(int,int);</o:p>

<o:p></o:p>Please see the following sample code in this
regard:<o:p></o:p>

PdfContentEditor contentEditor = new PdfContentEditor();

contentEditor.BindPdf("file.pdf");

contentEditor.DeleteStampById(100);

contentEditor.Save("outfile.pdf");

Please feel free to contact support in case you have any further queries.

Thank You & Best Regards,

Thanks. Unfortunately I am having problems restamping PDFs that were created by Aspose.Words and Aspose.Cells. I can remove the stamps successfully, but if I later add a new stamp to the PDF, it will appear twice - once in the new location and once in the location of the deleted stamp. This doesn’t happen on the first page, only on the second and later pages.

I will include sample code below and attach the input DOCX and the output PDF. You can see that the first page of the PDF has one stamp at the location 200, 200, while the second page has two stamps, one at 100, 100 and another at 200, 200.

string docxPath = @“C:\StampDeleteTest.docx”;
string pdfPath = @“C:\StampDeleteTest.pdf”;

Aspose.Words.Document doc1 = new Aspose.Words.Document(docxPath);
doc1.Save(pdfPath, SaveFormat.Pdf);

PdfFileStamp fileStamp1 = new PdfFileStamp(pdfPath, pdfPath);

Stamp stampPage1Attempt1 = new Stamp();

stampPage1Attempt1.BindLogo(new FormattedText(“Stamp Page 1, Attempt 1”));
stampPage1Attempt1.PageNumber = 1;
stampPage1Attempt1.StampId = 1;
stampPage1Attempt1.SetOrigin(100F, 100F);

fileStamp1.AddStamp(stampPage1Attempt1);

Stamp stampPage2Attempt1 = new Stamp();

stampPage2Attempt1.BindLogo(new FormattedText(“Stamp Page 2, Attempt 1”));
stampPage2Attempt1.PageNumber = 2;
stampPage2Attempt1.StampId = 2;
stampPage2Attempt1.SetOrigin(100F, 100F);

fileStamp1.AddStamp(stampPage2Attempt1);

fileStamp1.Close();

PdfContentEditor pdfContentEditor = new PdfContentEditor();

pdfContentEditor.BindPdf(pdfPath);

pdfContentEditor.DeleteStampById(stampPage1Attempt1.StampId);
pdfContentEditor.DeleteStampById(stampPage2Attempt1.StampId);

pdfContentEditor.Save(pdfPath);

PdfFileStamp fileStamp2 = new PdfFileStamp(pdfPath, pdfPath);

Stamp stampPage1Attempt2 = new Stamp();

stampPage1Attempt2.BindLogo(new FormattedText(“Stamp Page 1, Attempt 2”));
stampPage1Attempt2.PageNumber = 1;
stampPage1Attempt2.StampId = 3;
stampPage1Attempt2.SetOrigin(200F, 200F);

fileStamp2.AddStamp(stampPage1Attempt2);

Stamp stampPage2Attempt2 = new Stamp();

stampPage2Attempt2.BindLogo(new FormattedText(“Stamp Page 2, Attempt 2”));
stampPage2Attempt2.PageNumber = 2;
stampPage2Attempt2.StampId = 4;
stampPage2Attempt2.SetOrigin(200F, 200F);

fileStamp2.AddStamp(stampPage2Attempt2);

fileStamp2.Close();



Hi Reuben,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and sample code.

I am able to generate the issue you mentioned using the latest version of Aspose.Pdf for .NET v6.7. The issue has been registered in our issue tracking system with issue id: PDFNEWNET-33283. You will be notified regarding any updates against your issue via this forum thread.

Sorry for the inconvenience,

Thanks for your patience. Please note that the issues you have found earlier (filed as PDFNEWNET-33283) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.