1

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

faiz mir
  • 11
  • 1
  • Possible duplicate of [PDFBox API: How to handle Cyrillic values in an AcroForm field](https://stackoverflow.com/questions/47995062/pdfbox-api-how-to-handle-cyrillic-values-in-an-acroform-field) – Tilman Hausherr Jul 12 '19 at 09:57
  • Tried but same error – faiz mir Jul 12 '19 at 10:35
  • Then edit your question to include the code you used, and share the PDF that you used. If you can't share the PDF, then create one with the CreateSimpleForm.java example from the source code download. Make sure that you are using the latest PDFBox version, 2.0.16. – Tilman Hausherr Jul 12 '19 at 11:08

0 Answers0