나는 iText 라이브러리를 처음 사용합니다. 필자는 출력물을 PDF로 제공해야하는 요구 사항이 있습니다. pdf에는 아랍어 문자가 있습니다. 나는 아래와 같이 테스트 서블릿을 만들었다.Itext 아랍어 글꼴 물음표로 표시
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType ("application/pdf;charset=UTF-8");
Document document = new Document();
try{
PdfWriter.getInstance(document,
response.getOutputStream()); // Code 2
document.open();
Font f1;
BaseFont bf = BaseFont.createFont("C:\\WINDOWS\\Fonts\\ARIALUNI.ttf", BaseFont.CP1252, true);
f1 = new Font(bf, 10);
PdfPTable table = new PdfPTable(2);
table.addCell("hellooooo1");
table.addCell("world2");
table.addCell("1113");
table.addCell("422");
// String a = "يبسبيبيبيسسسيبيببيسبيسيببي";
String a = "سش";
PdfPCell cell = new PdfPCell (new Paragraph (a,f1));
table.addCell (cell);
cell = new PdfPCell (new Paragraph ("Road",f1));
table.addCell (cell);
document.add(table);
document.close();
}catch(DocumentException e){
e.printStackTrace();
}
}
우리가 아랍어 문자를 사용하는 출력은 ????? . 이 문제를 해결하는 방법? 나는 어디에서 실수하고 있니?
는 그 여전히 물음표 만으로 보여주는 ...'IDENTITY_H' –
성공하지'CP1252'를 교체하십시오. – vikka
단지 편집증 적이기 때문에, 테이블의 일부가 아닌 문서에 직접'a'를 추가하십시오. 그래도 작동하지 않는다면 PdfTable 클래스가 문제를 일으키는 것이 아니라는 것을 알고 있습니다. –