001077.pdf (1.2 MB)
Hi,
When applying PdfPageStamp to files of the same size I usually get the expected behavior, where the watermark is centralized in relation to the document.
With the attached file the results are different , the watermark is being applied off the center (more to the upper right), is there a way to fix this behavior?
Below some test code for reference:
public void asposeTest(String inputFile, String outputFile, String templatePath) {
Document pdfDoc = new Document(inputFile);
Document stampDoc = new Document(templatePath);
PdfPageStamp pageStamp = new PdfPageStamp(stampDoc.getPages().get_Item(1));
pageStamp.setBackground(false);
pdfDoc.getPages().get_Item(1).addStamp(pageStamp);
pdfDoc.save(outputFile);
}
@danielbeni
Would you please share the document used for the stamp along with an expected PDF output. We will test the scenario in our environment and address it accordingly.
I’ve attached a sample pdf, with its result (expected)
And the result I received from the problematic file.
Notice the watermark is off the center, this includes the watermark added by aspose itself too which is also not showing properly on the problematic file
The template file is the one used as watermark.
problem_with_watermark.pdf (1.2 MB)
sample_with_watermark.pdf (48.3 KB)
sample2.pdf (5.2 KB)
template.pdf (9.3 KB)
@danielbeni
We have checked the sample files that you have shared. The PDF document which you are using for stamping has a different page size (i.e. larger than the page size of the target document). Due to which, the stamp is off-centered.
We tried to adjust height/width of the stamp according to page dimensions but it did not work. We have logged an issue as PDFJAVA-39491 in our issue tracking system for it. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.
We are sorry for the inconvenience.
@danielbeni
Would you please try to set the Alignment of the stamp in order to resolve the issue you are facing:
Please, use the following option to render the stamp at the center of the page:
pageStamp.setHorizontalAlignment(HorizontalAlignment.Center);