2014-11-15 7 views
0
내가 자바 코드를 코딩하고 난 아랍어 단어를 PDF 문서에 첨부 된 그림과 같이

PDFTable iText를 아랍어

를 생성하여 itext 문서에 엉덩이이었다 PdfPTable에 표시하고 싶었

"???" 아랍어 코드 '입니다

PdfPTable header = new PdfPTable(6); 
PdfPTable tbame = new PdfPTable(1); 
tbame.addCell("         >>>>>>  " + install.getCustId().getFullName() + " <<<<<<"); 
tbame.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); 
tbame.setLockedWidth(false); 
tbame.setExtendLastRow(false); 
tbame.setWidthPercentage(100); 
header.addCell("End"); 
header.addCell("Start"); 

답변

1

설명서를 읽고 당신은 addCell(String content) 방법은 두 가지 이유에서 아랍어 텍스트를 추가 할 수 없습니다 것을 찾을 수 있습니다하십시오 :

  1. 이 방법의를 사용하는 경우 기본 글꼴 Helvetica가 사용됩니다. 아랍어 도형 그리는 방법을 알고있는 서체를 사용해야합니다. 이 질문에 대한 대답은 다음과 같습니다. Itext Arabic Font coming as question marks
  2. 아랍어는 오른쪽에서 왼쪽으로 쓰여졌습니다. 즉,이 질문에 대한 대답에서 설명한대로 셀 내용의 실행 방향을 변경해야합니다. RTL not working in pdf generation with itext 5.5 for Arabic text

코드 조각 : 당신은 글꼴 arialuni.ttf에 액세스 할 수없는 경우

BaseFont bf = BaseFont.createFont("c:/WINDOWS/Fonts/arialuni.ttf", 
    BaseFont.IDENTITY_H, BaseFont.EMBEDDED); 
Font font = new Font(bf, 12); 
Phrase phrase = new Phrase(
    "\u0644\u0648\u0631\u0627\u0646\u0633 \u0627\u0644\u0639\u0631\u0628", font); 
PdfPCell cell = new PdfPCell(phrase); 
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); 
table.addCell(cell); 

, 당신은 아랍어, 캐릭터를 포함한 다른 글꼴을 찾을해야합니다.