Hi,
I am trying to add a watermark to a page and getting an exception. When I even try to use the sample code (See below) from the aspose examples I get an error exception
Aspose.Pdf.Document document = new Aspose.Pdf.Document("C:\\Temp\\letter.pdf");
Aspose.Pdf.WatermarkArtifact artifact = new Aspose.Pdf.WatermarkArtifact();
artifact.SetTextAndState(
"LETTER NOT APPROVED",
new Aspose.Pdf.Text.TextState()
{
FontSize = 14,
ForegroundColor = Aspose.Pdf.Color.Red
});
artifact.ArtifactHorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
artifact.ArtifactVerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
artifact.Rotation = 45;
artifact.Opacity = 0.5;
artifact.IsBackground = true;
document.Pages[1].Artifacts.Add(artifact);
document.Save("c:\\temp\\watermark.pdf");
The exception is ‘System.NullReferenceException’
The artifact object properties Content and Rectangle show exceptions for Null Reference
The stack trace is
" at Aspose.Pdf.Artifact.#=z7SlCjBA=()\r\n at Aspose.Pdf.Artifact.#=zHa90LwE=()\r\n at Aspose.Pdf.Artifact.#=zEybCm1g=()\r\n at Aspose.Pdf.Artifact.#=zESWcYFjWAsiE(OperatorCollection #=zvWzJkiY=)\r\n at Aspose.Pdf.ArtifactCollection.Add(Artifact artifact)\r\n at …my stuff
Any insight or suggestions appreciated