itext Marathi(印度)语言显示问题 [英] itext Marathi (indian) language display issue

查看:235
本文介绍了itext Marathi(印度)语言显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估iText作为Java swing应用程序的PDFGenerator。输出应该是在马拉地语,这是一个印度当地语言类似于印地文,但不是相同的。

为了评估的目的,这是我正在尝试的文字打印:

$ p

这里是源代码:

  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;


公共类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(我的第一个PDF);


private static void addTitlePage(Document document)
throws DocumentException
{

段落序言=新段落();

FontFactory.registerDirectory(C:\\WINDOWS\\Fonts);

字体marFont = FontFactory.getFont(arial unicode ms,BaseFont.IDENTITY_H,true);

//让我们写一个大头文件
preface.add(new Paragraph(मराठीग्रीटींग्स,मराठीशुभेच्छापत्रे,marFont));

document.add(前言);


$ / code $ / pre

请检查以下图像以查看错误详情: p>



我认为这个问题可能是编码或者其他问题,但现在还不能解决。任何帮助将不胜感激。除非包含在最新版本中,否则iText不支持Devanāgarī写作系统。在一些书写系统中,实际的字母和正确的字形之间没有一一对应的关系,但是字形的形状根据例如周围的字形或其在一个单词中的位置。要正确呈现文本,类型设置软件需要实现这些规则和AFAIK,iText只为阿拉伯语执行这样的规则。


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.

解决方案

Unless included in one of the most recent versions, iText does not support the Devanāgarī writing system.

In some writing systems, there is no one-to-one relation between the actual letter and the correct glyph, but the glyph shape differs depending on e.g. the surrounding glyphs or its position within a word. To render the text correctly, the type setting software needs to implement these rules and AFAIK, iText implements such rules only for Arabic.

这篇关于itext Marathi(印度)语言显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆