I want to create Persian PDF using iTextsharp but when set HorizontalAlignment to Element.ALIGN_JUSTIFIED_ALL text displayed with large spaces between words. using spacecharratio property didn't help me. how can i solve this problem with useing HorizontalAlignment=Element.ALIGN_JUSTIFIED_ALL`?
FontSelector fontSelector = new FontSelector(); FontFactory.Register(Application.StartupPath + "\\fonts\\BNazanin.ttf"); Font BNazanin = FontFactory.GetFont("BNazanin", BaseFont.IDENTITY_H,BaseFont.EMBEDDED,10); FontFactory.Register(Application.StartupPath + "\\fonts\\Tahoma.ttf"); Font Tahoma = FontFactory.GetFont("Tahoma", BaseFont.IDENTITY_H,BaseFont.EMBEDDED, 10); if (BNazanin.Familyname != "unknown") { fontSelector.AddFont(BNazanin); } if (Tahoma.Familyname != "unknown") { fontSelector.AddFont(Tahoma); } PdfWriter Writer = PdfWriter.GetInstance(Doc, MemoryStream); Writer.PageEvent = new pageborder(); Writer.SpaceCharRatio = PdfWriter.NO_SPACE_CHAR_RATIO; Doc.Open(); PdfPTable Contract_Content = new PdfPTable(1); Contract_Content.HorizontalAlignment = Element.ALIGN_CENTER; Contract_Content.SpacingBefore = 5f; foreach (var item in content) { PdfPCell Content = new PdfPCell(); Paragraph p_content = new Paragraph(fontSelector.Process(item.Description)); p_content.Alignment = Element.ALIGN_JUSTIFIED_ALL; Content.AddElement(p_content); Content.PaddingRight = 40f; Content.DisableBorderSide(PdfPCell.BOTTOM_BORDER); Content.DisableBorderSide(PdfPCell.LEFT_BORDER); Content.DisableBorderSide(PdfPCell.RIGHT_BORDER); Content.DisableBorderSide(PdfPCell.TOP_BORDER); Content.RunDirection = PdfWriter.RUN_DIRECTION_RTL; Content.HorizontalAlignment = Element.ALIGN_JUSTIFIED_ALL; Content.PaddingBottom = 10f; Contract_Content.AddCell(Content); } Doc.Add(Contract_Content); -- View this message in context: http://itext.2136553.n4.nabble.com/ItextSharp-Solution-use-of-Align-Justified-All-in-Persian-text-tp4660870.html Sent from the iText mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php