Free Support Forum - aspose.com

How do I add text to an image?

The code below has created a function to insert text into the image.

Does the pdf api have that function?

code
public static void main(String[] args) {

	 try {
		final BufferedImage image = ImageIO.read(new URL("http://localhost:8080/img/watermark_emro_s.gif"));
		Graphics g = image.getGraphics();
		Color c = new Color(0,0,0);
		g.setColor(c);
		int height = image.getHeight() / 2;
		int width = image.getWidth() / 2;
		
		g.drawString("2020/03/26", width-30, height + 27);
		g.dispose();
		ImageIO.write(image,"gif", new File("D:\\test.gif"));
		
	} catch (MalformedURLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	 
}

test.gif (11.0 KB)

@emrods

We are afraid that Aspose.PDF does not support processing/manipulating images. It is dedicated to perform operations over PDF documents. In case you have further inquiry, please feel free to ask.

Thank you for your reply.