java - PDFbox runs into error (how to calculate the position for non-simple fonts) -
i using pdfbox fill form in pdf file, application able show number of available fields on form returns following error
messages: error: don't know how calculate position non-simple fonts file: org/apache/pdfbox/pdmodel/interactive/form/pdappearance.java line number: 616
code
..... while (fieldsiter.hasnext()) { pdfield field = (pdfield) fieldsiter.next(); setfield(pdf, field.getpartialname(), "my input"); //setfield(pdf, field.getfullyqualifiedname(), "my input"); } ..... public void setfield(pddocument pdfdocument, string name, string value) throws ioexception { pddocumentcatalog doccatalog = pdfdocument.getdocumentcatalog(); pdacroform acroform = doccatalog.getacroform(); pdfield field = acroform.getfield(name); if (field != null) { field.setvalue(value); } else { system.err.println("no field found name:" + name); } }
please let me know if need other part of code.
there seems bug in pdfbox occurs in various circumstances can't find relevant font. workaround i've been able find skipping update appearance code that's run in pdtextbox.setvalue
. can "force" value updated doing:
cosstring fieldvalue = new cosstring("awesome field value"); textbox.getdictionary().setitem(cosname.v, fieldvalue);
presumably, in corner cases, pdf viewer can handle rendering font, , setting v
item field should suffice. subjectively documents i've generated open fine in acrobat , os x preview.
related issue: https://issues.apache.org/jira/browse/pdfbox-1550
edit add: default acrobat seems create fields visible text area size of 0. documents problem, can around adding textbox.getdictionary().setitem(cosname.ap, null);
, hoping reader can handle rendering appearance correctly.
Comments
Post a Comment