我正在尝试使用Pdfbox 2.0填写现有表格,当我尝试用英语输入值时,它确实非常有用。但是问题是,当我尝试用捷克语输入值时,它的抛出错误使我从2天开始就尝试了所有可能的方法,但是如果有人可以帮助我,则无济于事。
PDResources resources = new PDResources();
resources.put(COSName.getPDFName("tipr"), PDType1Font.TIMES_ROMAN);
acroForm.setDefaultResources(resources);
通过此错误 java.io.IOException:找不到字体:/ 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')不能使用此字体Helvetica(通用:LiberationSans)编码:StandardEncoding有差异