We're sorry AsposeApp doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.app

Adding a stamp as an artifact in a pdf


I need to add an image stamp on an existing pdf, and this image needs to pass accessibility requirements.

If I understand correctly I need to use an artifact to achieve this. There was a similar question on the forum before- https://forum.aspose.com/t/marking-textstamp-as-artifact/200629, in which you suggested using an WatermarkArtifact.

However the WatermarkArtifact code throws a null exception, (WatermarkArtifact’s content and Rectangle properties also throw a null exception, not sure if that’s relevant)

I simply cannot find any example online to make this work- an image stamp/watermark/whatever that passes PDF/UA.

Here is my code. the last line throws the exception.

        Document pdfDocument = new Document(filePath);
        Artifact watermark = new WatermarkArtifact();

        FileStream file = new FileStream(imagePath , FileMode.Open);

        watermark.Position = new Aspose.Pdf.Point(x, y);
        watermark.Text = "Accessible";
        watermark.IsBackground = true;
        watermark.ArtifactHorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
        watermark.ArtifactVerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;

        pdfDocument.Pages[1].Artifacts.Add(watermark); - this throws a null exception

Any idea? Thank you!

This topic has been moved to the related forum: https://forum.aspose.com/t/adding-a-stamp-as-an-artifact-in-a-pdf/255796