Hi Tilman, I tried AcroForm.setNeedAppearances(true) in the past but you mentioned on Stackoverflow that the resulting document will only be readable on Adobe Reader, and I checked - only Adobe Reader renders it correctly - other readers display default values.
I'm not sure it's related to the JIRA issue you mentioned since I don't see any exception - PDF is generated correctly. I'll wait... Thanks, Mickael On Thu, Apr 27, 2017 at 9:29 PM, Tilman Hausherr <[email protected]> wrote: > Am 27.04.2017 um 20:24 schrieb Mickael Marrache: > >> Hi, >> >> Any news with this issue? >> > > Be patient... maybe he's busy... or maybe it is a known weakness: > https://issues.apache.org/jira/browse/PDFBOX-3138 > > We're not good with complex scripts and RTL fonts :-( > > What you could try, is to call AcroForm.setNeedAppearances(true). > > Tilman > > > >> Thanks, >> Mickael >> >> On Wed, Apr 26, 2017 at 1:34 PM, Mickael Marrache < >> [email protected] >> >>> wrote: >>> The PDF before filling: >>> >>> http://docdro.id/ybLln7x >>> >>> The PDF after filling: >>> >>> http://docdro.id/QcZfT9H >>> >>> On 2017-04-26 10:56 (+0300), Maruan Sahyoun <[email protected]> >>> wrote: >>> >>>> Hi, >>>> >>>> Am 26.04.2017 um 08:19 schrieb Mickael Marrache < >>>>> >>>> [email protected]>: >>> >>>> Hi, >>>>> >>>>> I'm trying to fill a PDF form using PDFBox 2.0.5 as follows: >>>>> >>>>> PDDocument pdfDocument = >>>>> PDDocument.load(this.getClass().getClassLoader(). >>>>> >>>> getResourceAsStream("form.pdf")); >>> >>>> PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); >>>>> >>>>> PDResources formResources = acroForm.getDefaultResources(); >>>>> PDTrueTypeFont font = (PDTrueTypeFont) >>>>> formResources.getFont(COSName.getPDFName("David,Bold")); >>>>> >>>>> TrueTypeFont ttFont = font.getTrueTypeFont(); >>>>> >>>>> PDFont font2 = PDType0Font.load(pdfDocument, ttFont, true); >>>>> ttFont.close(); >>>>> >>>>> formResources.put(COSName.getPDFName("F0"), font2); >>>>> >>>>> if (acroForm != null) { >>>>> PDTextField field = (PDTextField) acroForm.getField("full_name"); >>>>> field.setDefaultAppearance("/F0 10 Tf 0 g"); >>>>> field.setValue(/* hebrew text here*/); >>>>> } >>>>> >>>>> File targetFile = File.createTempFile("", ".pdf"); >>>>> pdfDocument.save(targetFile); >>>>> pdfDocument.close(); >>>>> >>>>> The reason I embed the David,Bold font is explained here >>>>> http://stackoverflow.com/questions/42903217/write- >>>>> >>>> cyrillic-chars-into-pdf-form-fields-with-pdfbox >>> >>>> >>>> could you upload a PDF before and after filling to a public location? >>>> >>>> BR >>>> Maruan >>>> >>>> >>>> . >>>>> >>>>> The issue is that the resulting PDF file has the text in the full_name >>>>> textbox displayed in the reverse direction. However, if I click on the >>>>> textbox, the text appears correctly. I precise that the text filled in >>>>> >>>> the >>> >>>> textbox is in Hebrew (right-to-left). >>>>> >>>>> Any idea? >>>>> >>>>> Thanks, >>>>> Mickael >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> >>> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

