pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Text appears reverted in textbox
Date Thu, 27 Apr 2017 22:13:53 GMT
OK, I had a look at this.

At this point in time PDFBox doesn't support the appearance generation for RTL text. The reason
you see the text reverted is because one would need to handle the text in visual order. 

So where PDFBox writes the string as 

\000\250\000\243\000\245\000\232\000\246

Adobe Reader writes the string as

\000\246\000\232\000\245\000\243\000\250

This could be fixed but wouldn't be sufficient to completely handle Hebrew and other languages
whith complex-text requirements (word forming, character shaping, BIDI …).

At that point in time PDFBox doesn't provide the capabilites needed. 

BR
Maruan


> Am 26.04.2017 um 12:34 schrieb Mickael Marrache <mickael@wakeuppension.com>:
> 
> 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 <sahyoun@fileaffairs.de> wrote: 
>> Hi,
>> 
>>> Am 26.04.2017 um 08:19 schrieb Mickael Marrache <mickaelmarrache@gmail.com>:
>>> 
>>> 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: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message