I am working with PDFBOX and the documentation on it seems sparse so I’ve come here for some help. I am trying to print out a pdf form that I’ve created, with fields populated dynamically by eclipse. I can get it to import and print, but when I do print, the fields I’ve set don’t show up (although they do when I save it to HDD). Can someone point me to the settings to set visible when printing? I saw itext had something similar, and I’m hoping that PDFBox does too.
Here is my current code.
PDDocument doc = null;
try{
doc = PDDocument.load("resources/orderForm.pdf");
PDDocumentCatalog docCatalog = doc.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
PDField field = acroForm.getField("Orderer");
field.setValue("JohnTest");
} catch (IOException ie){
System.out.println(ie);
}
//doc.addPage(new PDPage());
try{
//doc.save("Empty PDF.pdf");
doc.silentPrint();
//doc.print();
doc.close();
} catch (Exception io){
System.out.println(io);
}
}
found my answer, can’t use pdfbox to do it, although the alternative is just as simple. Use the desktop to print the file! example code as follows