it is not entirely source code compatible to pdfbox 2, so check out the migration guide. pdfbox replace text in pdf getpage ( 1) ; / / replace an image on the page rect target_ region = page. finally, save the output pdf using the document object' s save method.