Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bailey Evans   on Jul 12 In Java Category.

  
Question Answered By: Umaiza Hashmi   on Jul 12

I have a good solution to showing Persian text  to any export (pdf, word, html)

The problem  is some exports like pdf can not resolve Persian fonts  and you can not pass your text to parameter.

You need just convert your text to Unicode by \u0xxxx format and pass it to your parameter instead of original text.

public String toUnicode(String originalText)
{
String outPutText = new String();
boolean asciiText = false;
for(int i = 0; i < originalText.length(); i++)
if(originalText.substring(i, i + 1).compareTo("0") >= 0 && originalText.substring(i, i + 1).compareTo("9") <= 0)
{
int ii = Character.getNumericValue(originalText.charAt(i)) + 1632;
char ch = (char)ii;
outPutText = outPutText + Character.toString(ch);
} else
{
outPutText = outPutText + originalText.charAt(i);
}

return outPutText != null ? outPutText : "";
}

public String toAnsii(String unicodeText)
{
String outPutText = new String();
String wordTmp = new String();
int iii = 0;
int Len = 0;
int unicodeIndex = 0;
int asciiIndex = 0;
char c = '\0';
int i = 0;
do
if(i < unicodeText.length())
{
c = unicodeText.charAt(i);
if(c == '\\')
{
i++;
c = unicodeText.charAt(i);
switch(c)
{
case 117: // 'u'
outPutText = outPutText + (char)Integer.parseInt(unicodeText.substring(i + 1, i + 5).toString(), 16);
i += 5;
break;
}
} else
{
outPutText = outPutText + c;
i++;
}
} else
{
return outPutText != null ? outPutText : "";
}
while(true);
}

I hope can be resolved your problem, but If you feel your problem is remaing, I can send you a sample project.

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with Farsi fonts for dynamic text in iReport Or get search suggestion and latest updates.


Tagged: