Hello,
I am trying to print characters in Hindi using Aspose Words for Java. The characters are not being printed as the input text.
The sample code snippet is below -
-------------------------------------------------------------------------------------------------------------------
import java.awt.Color;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Set;
import com.aspose.words.AutoFitBehavior;
import com.aspose.words.Cell;
import com.aspose.words.CellFormat;
import com.aspose.words.CellMerge;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.Font;
import com.aspose.words.License;
import com.aspose.words.PreferredWidth;
import com.aspose.words.Table;
public class InternationalLanguages {
public static void main(String[] args) throws Exception
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
CellFormat cellFormat = builder.getCellFormat();
String dataDir = “docs/Temp/”;
Table table1 = builder.startTable();
builder.insertCell();
table1.setAllowAutoFit(false);
builder.getCellFormat().setVerticalMerge(CellMerge.NONE);
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.LIGHT_GRAY);
builder.write(“Language”);
builder.insertCell();
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.WHITE);
builder.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
builder.write(“हालाँकि सूर के जीवन के बारे में कई जनश्रुतियाँ प्रचलित हैं, पर इन में कितनी सच्चाई है यह कहना कठिन है। कहा जाता है उनका जन्म सन् १४७८ में दिल्ली के पास एक ग़रीब ब्राह्मीण परिवार में हुआ। जनश्रुति के अनुसार सूरदास जन्म से ही अंधे थे। आजकल थी अंधे आदमी अक्सर ‘सूरदास’ कहलाते हैं। कई लोगों ने उन्हें गुरु के रूप में अपनाया और उनकी पूजा करना शुरु कर दिया ।”);
builder.endRow();
builder.endTable();
doc.save(dataDir + “InternationalLanguages.doc”);
}
}
-------------------------------------------------------------------------------------------------------------------
This code gives desired output for languages such as English and Chinese but problems occur with languages Hindi,Punjabi and Bengali.
Also a screenshot of the final doc is attached for reference,
Please suggest a solution.
Thanks and regards,
Kautilya