I am using the BindXML method to generate a PDF from an XML file. I need to add a Stamp annotation into the PDF. How can I specify the Stamp inside the input XML file? (I have Aspose.Pdf version 8.4.0.0.)
If this cannot be done using BindXML, how else can I add it to the PDF after using BindXML? Can you provide some sample code?
Thanks for your inquiry. You can easily add a Stamp Annotation into a PDF file after XML to PDF conversion as follows:
You can save your XML to PDF resultant file in a stream and pass it to the document object for adding a Stamp Annotation. Hopefully, it will help you accomplish the task.
String imagePath = "logo.png";
Document doc = new Document("HelloWorld.pdf");
Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(100, 100, 200, 150);
StampAnnotation stampAnnot = new StampAnnotation(doc.Pages[1], rect);
stampAnnot.Width = 80;
stampAnnot.Height = 30;
stampAnnot.Name = "stampannotation";
stampAnnot.Contents = "";
stampAnnot.Title = "XXXX";
using (var image = new FileStream(imagePath, FileMode.Open))
{
stampAnnot.Image = image;
doc.Pages[1].Annotations.Add(stampAnnot);
}
doc.Save("stampannotation.pdf");
Please feel free to contact us for any further assistance.