pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: How to write arabic text in a pdf file
Date Tue, 13 Jun 2017 13:25:44 GMT
Hi,


> Am 13.06.2017 um 15:22 schrieb MELIQUE Denis (MORPHO) <denis.melique@morpho.com>:
> 
> Classification SAFRAN IDENTITY AND SECURITY :INDUSTRY CONFIDENTIAL
> 
> Hello, 
> 
> I'm using pdfbox version 2.0.6 on Linux 7.
> My Java program reads a pdf template file and fill some areas (image and text) to produce
a new pdf document .
> There is English text written LeftToRight and Arabic text to be written RightToLeft.
> 
> Here is an extract of  template document loading and configuration : 
> {code}
> ....
>            fontStream = classLoader.getResourceAsStream("arialbd.ttf");
> 
>            logger.debug("Loading PDF template file ");
>            doc = PDDocument.load(pdfTemplateStream);
> 
>            logger.debug("Loading font file into the document");
>            PDFont font =  PDType0Font.load(doc, fontStream); 
> 
>            // Will edit the page 0 
>            PDPage page = doc.getPage(0);
>            doc.setDocumentInformation(docInfo);
> 
>            PDPageContentStream content = new PDPageContentStream(doc, page,  PDPageContentStream.AppendMode.APPEND,
false, true);
> 
>            content.setFont(font, fontSize); ...
> {code}
> 
> 
> Here is an extract of adding text : 
> {code}
>        content.beginText();
>        content.showText(text);
>        content.endText();
> {code}
> 
> 
> My problem is that the Arabic text is not printed correctly into the pdf document, I
do not know Arab language so it is hard to see what is wrong but my feeling is that the text
is written in a wrong order...
> For example the following text composed of  'Single' + a slash +  the Arab translation
of the word 'Single' :  Single / زيارة واحدة Is printed like this : Single / ةرايز
ةدحاو
> 
> Any Idea what I should do to fix this ? 

writing Arabic text is not supported in the current version of PDFBox as are other languages
which require RTL and/or complex script.

It's not only about reversing the order of the string but selecting the correct shape for
a character based on it's position within a word.

BR
Maruan


> 
> Thank you.
> 
> 
> 
> 
> This message has been marked as INDUSTRY CONFIDENTIAL by MELIQUE Denis (MORPHO) on 06/13/2017
15:22:02.
> - - - - - 
> Ce message a été classifié INDUSTRY CONFIDENTIAL par MELIQUE Denis (MORPHO) le 13/06/2017
15:22:02.
> #
> " This e-mail and any attached documents may contain confidential or proprietary information.
If you are not the intended recipient, you are notified that any dissemination, copying of
this e-mail and any attachments thereto or use of their contents by any means whatsoever is
strictly prohibited. If you have received this e-mail in error, please advise the sender immediately
and delete this e-mail and all attached documents from your computer system."
> #
> 
> ---------------------------------------------------------------------
> 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