Note that there are some explanatory texts on larger screens.

plurals
  1. POiText unicode font issue
    primarykey
    data
    text
    <p>I have been working with ttf font in java using itext (lowagie) sdk. I would like to explain my problem by example. </p> <p>I have a table row where I want to show some text ( bengali ttf). The text is supposed to take 2 lines but it is taking 3 lines. The problem is, first line is showing only 5 words and huge white space at the end visually it appears like it can take 8 words easily. </p> <p>Please note that if I use English I don't face such problem. I assume that the bengali unicode is causing the problem. If there is any workout regarding the problem then it would be great.</p> <p>I re-explain my problem by example:</p> <pre><code>Output: Line1: AAA BBBB CCCC DDDD EEEE &lt;BLANK SPACE BLANK SPACE&gt;ENDOFLINE Line2: CC DD EE PP QQ RR SS EE &lt;BLANK SPACE BLANK SPACE&gt;ENDOFLINE Line3: CC DD EE PP QQ RR &lt;BLANK SPACE BLANK SPACE&gt;ENDOFLINE Expected: Line1: AAA BBBB CCCC DDDD EEEE CC DD EE PP #ENDOFLINE Line2: QQ RR SS EE CC DD EE PP QQ RR #ENDOFLINE </code></pre> <p>Source Module:</p> <pre><code>fontpath="D://Bangla.ttf"; this.banglaFont = BaseFont.createFont(fontpath,BaseFont.IDENTITY_H,BaseFont.EMBEDDED); PdfPTable bTable = new PdfPTable(1); bTable.getDefaultCell().setBorder(1); bTable.setWidthPercentage(100); bTable.addCell(backTableRow1cell(28.5f, 8.8f, CardStr.GOVTNOTE_BNG)); public static PdfPCell backTableRow1cell(float hght, float fontSize, String txt) { PdfPCell c1 = new PdfPCell(); c1.setFixedHeight(hght); c1.setHorizontalAlignment(Element.ALIGN_RIGHT); ITextUtil.setCellBorder(c1, 0, 0, 1, 0); ITextUtil.setCellPadding(c1, 0, 7, 0, 0); c1.addElement(TextProcessing.designPar(TextProcessing.getFontStyle(VoterCard.banglaFont, fontSize, Color.BLACK, Font.NORMAL), txt, Element.ALIGN_LEFT, 8, 2)); return c1; } public static Paragraph designPar(Font fnt, String txt, int alignment, int leading, int afterspacing) { Paragraph phrs = new Paragraph(txt, fnt); phrs.setLeading(leading); phrs.setAlignment(alignment); return phrs; } public static Font getFontStyle(BaseFont baseFont, float size, Color clr, int FontStyle) { Font fnt = new Font(baseFont, size); fnt.setColor(clr); fnt.setStyle(FontStyle); return fnt; } </code></pre> <p><img src="https://i.stack.imgur.com/Iexxm.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload