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

Free Support Forum - aspose.com

I can't see the watermark. What should I do?

The pdf file that transformed the image does not perform the watermark function properly.
I attached the pdf file. Please check the watermark function test.
test version : aspose-pdf 19.2

------------ watermark code-----------------------
public Document setWatermark(Document document, String imagePath, Map<String,Object> mappingInfo) {

	// create stamp
	ImageStamp imageStamp = makeImageStamp(imagePath);
	TextStamp headerStamp = makeHeaderStamp(mappingInfo);
	TextStamp footerStamp = makeFooterStamp(mappingInfo);
	PageNumberStamp numberStamp = makePageNumberStamp(document);
	
	// add stamp in all pages
	Iterator<Page> pages = document.getPages().iterator();
	while(pages.hasNext()){
		Page page = pages.next();
		page.addStamp(imageStamp);
		page.addStamp(headerStamp);
		page.addStamp(footerStamp);
		page.addStamp(numberStamp);
	}
	imageStamp.close();
	
	return document;
}

test pdf file :
pdf file that transformed the image.pdf (79.6 KB)

@emrods

Would you please share the definitions of the methods used in your code snippet i.e. makeImageStamp(), makeHeaderStamp, etc? We will test the scenario in our environment and address it accordingly. Also, please make sure to use Aspose.PDF for Java 21.10 before sharing the requested information.

I’m sorry.

It’s a function logic you mentioned.

public ImageStamp makeImageStamp(String imagePath){
ImageStamp imageStamp = null;
try {
URL url = new URL(imagePath);
URLConnection conn = url.openConnection();
imageStamp = new ImageStamp(conn.getInputStream());
//imageStamp = new ImageStamp(“파일경로”);
} catch (Exception e) {
throw new EdocException("AsposePdfUtil.makeImageStamp() : "+ e.getMessage(), e.toString());
}

	imageStamp.setBackground(true);
	imageStamp.setOpacity(0.3);
	imageStamp.setHorizontalAlignment(HorizontalAlignment.Center);
	imageStamp.setVerticalAlignment(VerticalAlignment.Center);
	imageStamp.setWidth(220);
	imageStamp.setHeight(220);
	
	return imageStamp;
}

When I did page.addStamp using ImageStamp, the pdf I attached did not become ImageStamp.
Please test it with the pdf file I attached.

@emrods

Please try to replace the imageStamp.setBackground(true); with imageStamp.setBackground(false); and add the stamp again. In case you still face any issues, please let us know.