I am evaluating iText as a PDFGenerator for java swing application. The output is supposed to be in "Marathi", which is a local Indian langauge similar to hindi but not same.
For evaluation purposes this is the text i am trying to print:
मराठी ग्रीटींग्स, मराठी शुभेच्छापत्रे
Here is the source code:
package pdftest;
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfWriter;
public class CPDFTest
{
private static String FILE = "c:/will/FirstPdf.pdf";
public static void main(String[] args)
{
try
{
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(FILE));
document.open();
addMetaData(document);
addTitlePage(document);
document.close();
}
catch (Exception e)
{
}
}
private static void addMetaData(Document document)
{
document.addTitle("My first PDF");
}
private static void addTitlePage(Document document)
throws DocumentException
{
Paragraph preface = new Paragraph();
FontFactory.registerDirectory("C:\\WINDOWS\\Fonts");
Font marFont = FontFactory.getFont("arial unicode ms",BaseFont.IDENTITY_H,true);
// Lets write a big header
preface.add(new Paragraph("मराठी ग्रीटींग्स, मराठी शुभेच्छापत्रे", marFont));
document.add(preface);
}
}
Please check the following image for error details:
I think the issue maybe with the encoding or something but am not able to figure it out as of now. Any help will be appreciated.