在macintosh(OS Sierra)上,使用java创建pdf文件的日语“字符集”和“字体”的最佳组合是什么?
任何帮助将不胜感激。 谢谢。 代码片段在此处给出:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class PdfCharacterSet {
/*
* This will create a pdf file with the name of hello.pdf in the directory where this java file is executed.
*/
public static final String DEST = "..\\hello.pdf";
public static void main(String[] args) throws DocumentException, IOException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new PdfCharacterSet().createPdf(DEST);
}
public void createPdf(String dest) throws DocumentException, IOException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
// text is "日本列島における人類の歴史は";
String text = "\u65E5\u672C\u5217\u5CF6\u306B\u304A\u3051\u308B\u4EBA\u985E\u306E\u6B74\u53F2\u306F";
Font baseFont = FontFactory.getFont("arial unicode ms", "Shift_JIS");
document.add(new Paragraph(text, baseFont));
document.close();
}
}