2013-03-04 3 views
3

C#을 사용하여 아랍어로 PDF를 만들 때이 코드를 사용하면 생성 된 PDF 파일에 개별 문자가 포함됩니다. 어떤 도움이라도 나는 연속적인 캐릭터를 얻을 수 없습니까?itextsharp에서 아랍어 인코딩

//Create our document object 
Document Doc = new Document(PageSize.LETTER); 

//Create our file stream 
using (FileStream fs = new FileStream(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.pdf"), FileMode.Create, FileAccess.Write, FileShare.Read)) 
{ 
    //Bind PDF writer to document and stream 
    PdfWriter writer = PdfWriter.GetInstance(Doc, fs); 

    //Open document for writing 
    Doc.Open(); 

    //Add a page 
    Doc.NewPage(); 

    //Full path to the Unicode Arial file 
    string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "arabtype.TTF"); 

    //Create a base font object making sure to specify IDENTITY-H 
    BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); 

    //Create a specific font object 
    iTextSharp.text.Font f = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL); 

    //Write some text, the last character is 0x0278 - LATIN SMALL LETTER PHI 
    Doc.Add(new Phrase("This is a ميسو ɸ", f)); 

    //Write some more text, the last character is 0x0682 - ARABIC LETTER HAH WITH TWO DOTS VERTICAL ABOVE 
    Doc.Add(new Phrase("Hello\u0682", f)); 

    //Close the PDF 
    Doc.Close(); 
} 
+0

나는이 직면 한 : 이제 테이블에 예를 들어, 아랍어 텍스트를 추가 할 수 있습니다

BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(bf, 12); 

:

은 어떤 경우에, 당신은 아랍어 문자 모양을 표시하는 방법을 알고있는 폰트를 필요 문제가되기 전에, 당신은 내 질문에 "아랍어 변환"유니 코드 "itextsharp를 사용하여 pdf에 콘텐츠 HTML 또는 XML을"당신을 도울 수 있습니다 http://stackoverflow.com/questions/16080741/convert-arabicunicode-content-html- 또는 -xml-to-pdf-using-itextsharp –

답변

3

오른쪽에서 왼쪽 쓰기 및 아랍어 합자 만 ColumnTextPdfPTable에서 지원됩니다!

다음의 예를 살펴 보자 결과

이러한 예는 이유를 찾기 위해 수행되는에서 책을 읽고 모든 단어가 올바르게 표현되지는 않습니다 .pdf

검색 http://tinyurl.com/itextsharpIIA2C11이 해당 예제의 해당 C# 버전입니다.

PdfPCell cell = new PdfPCell(); 
cell.AddElement(new Phrase("Hello\u0682", f)); 
cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; 
관련 문제