我正在尝试使用 Pdfbox 2.0 填写现有表格,当我尝试用英文输入值时,它真的很好用。但问题是,当我尝试将值放在捷克语中时,它的抛出错误从 2 天开始就被困住了,尝试了所有可能的方式,但如果有人可以帮助我解决这个问题,那也无济于事。
PDResources resources = new PDResources();
resources.put(COSName.getPDFName("tipr"), PDType1Font.TIMES_ROMAN);
acroForm.setDefaultResources(resources);
通过这个错误 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') 在此字体中不可用 Helvetica (generic: LiberationSans) encoding: StandardEncoding with Difference