Hi Team,
I have a requirement to add a QR code on PDF and later on it should be removed from the file.
So I use below code to add the QR code image in to PDF.
//Open document
Document pdfDocument = new Document("input.pdf");
//Create image stamp
ImageStamp imageStamp = new ImageStamp("aspose-logo.jpg");
imageStamp.Background = true;
imageStamp.XIndent = 100;
imageStamp.YIndent = 100;
imageStamp.Height = 300;
imageStamp.Width = 300;
imageStamp.Rotate = Rotation.on270;
imageStamp.Opacity = 0.5;
//Add stamp to particular page
pdfDocument.Pages[1].AddStamp(imageStamp);
//Save output document
pdfDocument.Save("output.pdf");
Now I want to remove the image stamps that I have added. How can I remove the image stamps from PDF?
Hi Dinesh,
Thanks for using our API’s.
Hi Team,
I am adding a QR code on every page of PDF and that PDF can have other images too and actually I don't know what is the index of QR code image.
I just want to remove the QR code image from the PDF and which index can be anything in resources.images.
Is there any other way other than index or can I know the index of my QR code image?
Regards,
Dinesh
Hi Dinesh,
Thanks for your inquiry. There is another convenient way to delete watermark with Aspose.Pdf using DeleteStampById() method but in this case watermark must be added using Aspose.Pdf API with IDs.
However, I am afraid this method is malfunctioning at the moment, so we have logged an investigation ticket as PDFNEWNET-36816 for further investigation and resolution. We will notify you via this forum thread as soon as it its resolved.
//Open document
Document
pdfDocument11 = new Document(myDir
“PageNumber.pdf”);
//Create image
stamp
ImageStamp imageStamp =
new ImageStamp(myDir
“aspose_pdf.jpg”);
imageStamp.Background = true;
imageStamp.XIndent = 100;
imageStamp.YIndent = 100;
imageStamp.Height = 300;
imageStamp.Width = 300;
imageStamp.Rotate = Rotation.on270;
imageStamp.Opacity = 0.5;
imageStamp.setStampId(111);
//Add stamp to
particular page
pdfDocument11.Pages[1].AddStamp(imageStamp);
//Save output
document
pdfDocument11.Save(myDir+“output_imageStamp.pdf”);
//Removing Stamp//
PdfContentEditor
contentEditor = new PdfContentEditor();
contentEditor.BindPdf(myDir + “output_imageStamp.pdf”);
StampInfo[] stampInfo
= contentEditor.GetStamps(1);
//contentEditor.DeleteStampById 4(111);
//Loop through
each stamp
for (int i = 0; i < stampInfo.Length; i++)
{
//Check to see if
the ID = 111, if so delete the stamp.
if (stampInfo[i].StampId
== 111)
{
contentEditor.DeleteStampById(stampInfo[i].StampId); }
}
contentEditor.Save(myDir + “output_deletedstamp.pdf”);
Best Regards,
The issues you have found earlier (filed as PDFNEWNET-36816) have been fixed in Aspose.Pdf for .NET 9.3.0.
Blog post for this release can be viewed over this link
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.