支持打印中的特殊字符

时间:2014-06-26 11:14:36

标签: java printing special-characters

更准确的问题是Here

我有这个包含员工姓名和信息的dbf数据库文件......我的java应用程序从这个数据库中读取行并准备一些文件(如工作证书......)。我来自哪里,我们在名字中使用特殊字符,因为它是法语国家。例如“Hédia”或“fayçal”。这里的问题是数据库包含所提到的带有特殊字符的名称,并且在打印有问题的文件时,不支持字符,而是显示空白空格。 我希望我能说清楚。

那么有没有办法以编程方式使打印支持这些字符?

我知道java中有Locale类,但我不知道是否可以将它用于打印目的。

我希望这个问题能够得到解决,并提前感谢您的帮助。

编辑: 通过我使用普通表构造函数的方式创建表并向其添加数据我正在使用从数据库中获取数据并返回Object []的类,以及此类的for方法它不止一行。

这是我的表格打印代码(我还将表格打包成格式化页眉和页脚):

     final MessageFormat headerFormat = new MessageFormat(builder.toString(), Locale.FRANCE);
         PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
            aset.add(OrientationRequested.LANDSCAPE);
            aset.add(PrintQuality.HIGH);
            Bulletin.print(PrintMode.FIT_WIDTH, headerFormat, null, true, aset, true);

         }catch (PrinterException pe) {
             String s= "Une erreur est survenue lors de l'impression, vérifier que votre imprimante est connectée \n Si le problème persiste, contacter la personne qui s'occupe de votre système";
              JOptionPane.showMessageDialog(Bulletin, s, "Erreur d'impression", 1);

         } catch(IndexOutOfBoundsException e){

             JOptionPane.showMessageDialog(Bulletin, "Aucun bulletin dans la liste. Veuillez au moins ajouter une entrée.\n Pour ajouter une entrée, cliquez sur le menu \"Gérer les Assurances\" puis sur \"Ajouter un Bulletin\".", "Aucun Bulletin selectionné", 1);

         }

要构建textpane,它是默认构造函数以及获取数据并将该数据添加到jtextpane中包含的默认文本的方法(顺便说一下,JTextPane的类型是html)。

这个用于打印文本窗格(这是JTextPane的默认打印方法):

public void print()
{
    MessageFormat headerMessage=new MessageFormat("Header");
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(OrientationRequested.PORTRAIT);
    aset.add(PrintQuality.HIGH);
    try {
        attest.print(headerMessage, null, true, null, aset, true);
    } catch (PrinterException e) {
        e.printStackTrace();
    }
}

0 个答案:

没有答案
相关问题