I'm currently working with PDFBox to create a PDF where the necessary spots are filled with the correct information. I have my string in the project, but for some reason, I cannot put that string into a pdf file with the doc.save();
functionality.
Is there any way to do such things, or should I approach this problem with a different manner?
public static void main(String[] args) {
String fileName = "testPDF.pdf";
try{
PDDocument doc = PDDocument.load(new File("sample.pdf"));
String text = new PDFTextStripper().getText(doc);
String name = text.replace("nameReplace", "Example Ethan");
doc.save(fileName);
doc.close();
}
catch(IOException e){
System.out.println(e.getMessage());
}
}