我正嘗試使用JZOS和iText在z/OS上創建PDF。z/OS上的JZOS和iText
我已經嘗試瞭如此多的字體以及DefaultPlatformEncoding的組合,但我似乎無法獲得阿拉伯字符顯示在PDF中。它們顯示爲拉丁字符。當關閉PDF壓縮並顯示十六進制字符時,我會看到EBCDIC十六進制代碼。
z/OS上的輸入文件是IBM-420,輸出PDF應該具有Cp1256或Windows-1256以便在Windows上顯示。
下面是代碼的片段:
// 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.register( 「ARIAL.TTF」)上傳;
Font cf = FontFactory.getFont(「Arial」,8);
paragraph = new Paragraph(line,cf);
在PDF的字體信息顯示如下:
ArialMT 類型:TrueType字體 編碼:安思 實際字體: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
[如何使用eclipse在pdf中創建波斯語內容](http://stackoverflow.com/questions/26818555/how-to-create-persian-content-in-pdf-using-eclipse) –
PDF中字體的「未知」是由於輸出PDF中的錯誤,這與iText無關。 – user1579878