pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilad Denneboom <gilad.denneb...@gmail.com>
Subject Re: Text appears reverted in textbox
Date Fri, 28 Apr 2017 09:12:56 GMT
When I faced a similar issue I followed Tilman's advice in the JIRA issue I
opened about it (and which was linked to above), and it worked fine.
Basically what I did was create the form fields in Acrobat in advance and
set them as having Adobe Hebrew as their font.
That forces the font to be embedded in the PDF.
I then applied the value using PDFBox and set the NeedsAppearances flag as
true.
When I open the file in Acrobat/Reader the text appeared correctly.
I'm not sure about other PDF viewers, though. They are generally
problematic when it comes to form fields in general, so I try to avoid them.

On Fri, Apr 28, 2017 at 5:44 AM, Mickael Marrache <mickaelmarrache@gmail.com
> wrote:

> Thanks for looking at this.
>
> Is there an estimate for when PDFBox will be able to support it?
>
> Could you please propose alternative libraries that we can use in the
> meantime? Free libraries preferred but not only.
>
> Thanks,
> Mickael
>
> Le 28 avr. 2017 01:14, "Maruan Sahyoun" <sahyoun@fileaffairs.de> a écrit :
>
> > 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message