I am trying to fill the existing form using Pdfbox 2.0 it really work great when i try to put the value in English. But the problem is when i try to put the value in czech language its throw error i am stuck with this from 2 days tried all possible way but doesn't help if anyone can help me with this.
PDResources resources = new PDResources();
resources.put(COSName.getPDFName("tipr"), PDType1Font.TIMES_ROMAN);
acroForm.setDefaultResources(resources);
through this error java.io.IOException: Could not find font: /Helv
for(String name : files) {
try (InputStream resource = getClass()
.getResourceAsStream("")) {
Path path = Paths.get(targetpath.substring(1));
//Path path =
Paths.get(targetpath.substring(1)+"/CandidateDocument_"+id);
Files.createDirectories(path);
String fullPath = filrpath + "/" + name;
System.out.println("Filename is:" + filrpath);
File file = new File(fullPath);
PDDocument pdfDocument = PDDocument.load(file);
PDDocumentCatalog docCatalog =
pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
List<PDField> fields = acroForm.getFields();
for (PDField field : fields) {
list(field);
}
if (acroForm != null) {
PDTextField pdfField;
pdfField = (PDTextField) acroForm.getField("name and surname");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(fullName);
}
pdfField = (PDTextField) acroForm.getField("name");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(firstName);
}
pdfField = (PDTextField) acroForm.getField("surname");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(lastName);
}
pdfField = (PDTextField) acroForm.getField("date of birth");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(dateOfBirth);
}
pdfField = (PDTextField) acroForm.getField("passport number");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(passportNumber);
}
pdfField = (PDTextField) acroForm.getField("position");
if(pdfField!=null)
{
pdfField.getWidgets().get(0).setHidden(false);
pdfField.setValue(position);
}
}
pdfDocument.setAllSecurityToBeRemoved(true);
COSDictionary dictionary = pdfDocument.getDocumentCatalog().getCOSObject();
dictionary.removeItem(COSName.PERMS);
pdfDocument.save(new File(targetpath.substring(1), name));
pdfDocument.close();
}
}
java.lang.IllegalArgumentException: U+011B ('ecaron') is not available in this font Helvetica (generic: LiberationSans) encoding: StandardEncoding with differences