Reversible strings from right to left (bidirectional) languages ​​in iTextSharp

I am using iTextSharp (C # iText port) to create PDF files from text / html. Most of my text is written in Hebrew, from right to left.

My problem is that PDF files show RTL langauge in reverse order, so I need to cancel my lines so that only RTL text can only be undone without changing any numbers or English text. I understand that fribidi allows you to do this on linux, but I could not find a solution to this problem for Windows.

I would welcome any suggestions, including iTextSharp alternatives, that will do this automatically (if any).

+5
source share
4 answers

To show RTL texts with iTextSharp correctly:

  • You need to set the font encoding to BaseFont.IDENTITY_H
  • Then you need to use container elements that support RunDirection, for example PdfPCell, ColumnTextetc., and now you can set them element.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
+7
source

PDFCreator is a free tool to create PDF files from virtually any Windows application. It is installed as a Windows printer driver, so that it can be used by any Windows program that has a print function. A.

You can treat your input as simple text strings for printing, and perhaps using the printmenu option Notepadwill create the correct PDF.

C#, StringFormatFlags.DirectionRightToLeft Graphics.DrawString().

PrintPage Event Handler:

lineFmt = new StringFormat(StringFormatFlags.DirectionRightToLeft);
e.Graphics.DrawString(textToPrint, font, Brushes.Black, startX, ypos, lineFmt);
+1

:

PdfPCell cell1 = new PdfPCell(new Phrase("מספר",font));
cell1.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right
+1

HTML / , PDF Visual. , Logical Visual. , (google minibidi, BSD IMHO, fribidi, GPL LGPL).

My current proposal would be to change direction. Write a very small application in Qt4 that takes a URL as the first argument and a PDF file as the second. Since Qt4 supports HTML (via QtWebKit), it is possible to print to PDF (post script and SVG), this should be easier than writing your own HTML-> PDF solution.

0
source

All Articles