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

Free Support Forum - aspose.com

Increased opacity of watermark after page 1

Using the artifact object in my code makes it go to the first sheet with the opacity I want but after the first sheet the opacity returns to 1. Example:

watermark.pdf (865.2 KB)

This is the code I am working with:
public static void main(String[] args) throws Exception {// Main function to add watermark to PDF in Java
// Initialize License Instance
License license = new License();
// Call setLicense method to set license

	long startTime = System.currentTimeMillis();
	// Load PDF document
	Document doc = new Document("src/marcaDeAgua/AyDSI_I_-_Clase_1.pdf");
	// Create formatted text
	FormattedText formattedText = new FormattedText("Restringido", java.awt.Color.BLUE, FontStyle.Courier,
			EncodingType.Identity_h, true, 20);
	//Crea el Watermark
	WatermarkArtifact artifact = new WatermarkArtifact();
	//Setea la marca de agua en la hoja por primera vez para recuperar despues sus medidas
	//Ancho y altura del artefacto
	double anchoWt = artifact.getRectangle().getWidth();
	double alturaWt = artifact.getRectangle().getHeight();
	// For de la hoja a trabajar
	for (int i = 1; i <= doc.getPages().size(); i++) {

		Rectangle mediabox = doc.getPages().get_Item(i).getMediaBox();

		// For de la altura para el watermark
		for (double h = 0; h <= mediabox.getHeight(); h = h + (alturaWt + 10)) {
			// For para el ancho para el watermark
			for (double w = 0; w <= mediabox.getWidth(); w = w + (anchoWt+8)) {

				// Pointer de la ubicacion del watermark
				Point point = new Point(w, h);
				//Setea la marca de agua en la hoja


	// Save watermarked PDF document
	long tarda = System.currentTimeMillis() - startTime;


Can you please share the respective input document as well? We will test the scenario in our environment and address it accordingly.

of course, here is the input doc:
AyDSI_I_-_Clase_1.pdf (206.6 KB)

but you can do it with any pdf and the resut will be the same.


We were able to notice the issue in our environment while testing the case with 22.12 version of the API. Hence, it has been logged as PDFJAVA-42373 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thank you, I’ll wait for the reponse.