z/OS上的JZOS和iText
我正在尝试使用JZOS和iText在z/OS上创建PDF 我尝试了很多字体组合以及DefaultPlatformEncoding,但我似乎无法在PDF中显示阿拉伯字符。它们显示为拉丁字符。当我关闭PDF压缩并显示十六进制字符时,我看到EBCDIC十六进制代码 z/OS上的输入文件是IBM-420,输出PDF应该有Cp1256或Windows-1256,以便在Windows上显示 以下是代码片段:z/OS上的JZOS和iText,itext,Itext,我正在尝试使用JZOS和iText在z/OS上创建PDF 我尝试了很多字体组合以及DefaultPlatformEncoding,但我似乎无法在PDF中显示阿拉伯字符。它们显示为拉丁字符。当我关闭PDF压缩并显示十六进制字符时,我看到EBCDIC十六进制代码 z/OS上的输入文件是IBM-420,输出PDF应该有Cp1256或Windows-1256,以便在Windows上显示 以下是代码片段: // Open the input dataset ZFile zFilein = new ZFil
// Open the input dataset
ZFile zFilein = new ZFile("//DD:INDS", "rb,type=record,noseek");
// Open the output PDF file
PdfWriter writer = PdfWriter.getInstance(document,
FileFactory.newBufferedOutputStream("//DD:OUTPDF"));
document.open();
// Font cf = new Font(Font.FontFamily.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
// Font cf = FontFactory.getFont("Courier","Cp1256", true);
Font cf = FontFactory.getFont("Arial", BaseFont.IDENTITY_H, true, Font.DEFAULTSIZE, Font.NORMAL);
Paragraph paragraph = new Paragraph();
paragraph.setFont(cf);
String encoding = ZUtil.getDefaultPlatformEncoding();
// String encoding = "Cp1256";
String line = new String(recBuf,1,nRead-1,encoding);
paragraph.add(line);
我尝试了以下选项,但仍然无法正确显示PDF,并且
PDF字体信息不显示嵌入的字体。还有什么我错过的吗
注意:arial.ttf是从WINDOWS上载的
选择1
FontFactory.registerarial.ttf;
Font cf=FontFactory.getFontArial,8
段落=新段落行,cf
PDF中的字体信息显示以下内容:
阿里亚尔姆特
类型:TrueType
编码:Ansi
实际字体:ArialMT
实际字体类型:TrueType
Option 2
BaseFont bf = BaseFont.createFont(font1, BaseFont.IDENTITY_H, true);
Font cf = new Font(bf, 10);
paragraph = new Paragraph(line, cf);
Viewing the PDF display the following error:
Cannot extract the embedded font 'ZQRNLC+ArialMT'. Some characters may not display or
print correctly.
Viewing the source of the PDF in an editor I can see the following:
R/FontName/ZQRNLC+ArialMT/
The FONT in the PDF displays the following information:
ArialMT
Type: TrueType(CID)
Encoding: Identity-H
Actual Font: Unknown
你的问题是其他几个问题的重复 这行代码可能有问题:
Font cf = FontFactory.getFont("Arial", BaseFont.IDENTITY_H, true, Font.DEFAULTSIZE, Font.NORMAL);
除非您已注册了Arial字体程序(如我对问题的回答中所述),否则这不会为您提供Arial字体
我不知道z/OS从未听说过它,但如果它使用EBCDIC,它就做错了。您的字符串必须使用UNICODE。正如我在回答问题时所解释的那样,使用的字符串值采用正确的编码是非常重要的。在本例中,您正在从文件中读取内容,但无法保证用于读取文件的编码与用于存储文件的编码匹配。当你说符号显示在EBCDIC中时,我认为你错了,你遇到了与中解释的相同的问题。你真的需要Unicode
您说您想用阿拉伯语创建文本,但我看不到您在任何地方使用RTL设置。我在回答这个问题时解释了这一点:
请下载免费电子书,你会注意到所有这些问题之前都被问过并回答过。我想将您的问题作为的副本结束,但不幸的是,该答案未被接受,且未获得追加投票,因此不能将其作为原始问题来标记另一个问题为副本。PDF中字体“未知”的可能副本是由于输出PDF中的损坏,这与iText无关。