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

Free Support Forum - aspose.com

Add Watermark in all PDF Pages using Java - inconsistency in watermarks

Hi,
I am facing an issue with aspose pdf for java API, i have written code to add watermark for all pages in the document however my Watermark gets correct for the first page only and rest of the pages just has the bold text as the watermark.
image.png (45.9 KB)
This is the image of the watermark not applying correctly

Following is my code:
// Create a formatted text for watermark
String watermarkString = getWatermark(attachment).get(“watermark”).toUpperCase(Locale.ROOT);
FormattedText formattedText = new FormattedText(watermarkString, java.awt.Color.RED,
FontStyle.Helvetica, EncodingType.Identity_h, true, 37.0F);

    // Create watermark artifact and set its properties
    WatermarkArtifact artifact = new WatermarkArtifact();
    artifact.setText(formattedText);
    artifact.setArtifactHorizontalAlignment (HorizontalAlignment.Center);
    artifact.setArtifactVerticalAlignment (VerticalAlignment.Center);
    artifact.setLeftMargin(210);
    artifact.setTopMargin(310);
    artifact.setRotation (50);
    artifact.setOpacity (0.5);
    artifact.setBackground (true);

    // Add watermark and footer to the PDF
    for (Page page: doc.getPages()){
        page.getArtifacts().add(artifact);
        page.addStamp(footerStamp);
    }

@ahmedtariq

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF document.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please create a sample application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

HI, Kindly refer to the zip attached. Looking forward to your response
WatermarkAspose.zip (8.4 MB)

Hi,
Kindly refer to the zip file attached

WatermarkAspose.zip (8.43 MB)

@ahmedtariq

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFJAVA-41180. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Okay sure,
We are short on deadline for this project, i hope this issue gets resolved soon.

@ahmedtariq

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

We will be sure to inform you via this forum thread once there is an update available on this issue.

Hi Tahir,
When can I expect to get an update on this watermark issue? We are testing the APIs and are planning to buy them next month but this issue will be a hindrance to that.

Thanks

@ahmedtariq

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.