iText 7 pdfCalligraph
pdfCalligraphを使用すると、PDFタイポグラフィの高度なワークフロー機能を明らかにできます。データ処理に適したPDFレンダリングライブラリ、編集オプションなどを含む、グローバル言語や書記体系に対応でき文書ワークフローを拡張します。
Supported Scripts
Language | Script | Module |
---|---|---|
Arabic, Persian, Kurdish, Azerbaijani, Sindhi, Pashto, Lurish, Urdu, Mandinka, Punjabi and others | ARABIC | pdfCalligraph |
Hebrew, Yiddish, Judaeo-Spanish, and Judeo-Arabic | HEBREW | pdfCalligraph |
Bengali | BENGALI | pdfCalligraph |
Hindi, Sanskrit, Pali, Awadhi, Bhojpuri, Braj Bhasha, Chhattisgarhi, Haryanvi, Magahi, Nagpuri, Rajasthani, Bhili, Dogri, Marathi, Nepali, Maithili, Kashmiri, Konkani, Sindhi, Bodo, Nepalbhasa, Mundari and Santali | DEVANAGARI, NAGARI | pdfCalligraph |
Gujarati and Kutchi | GUJARATI | pdfCalligraph |
Punjabi | GURMUKHI | pdfCalligraph |
Kannada, Konkani and others | KANNADA | pdfCalligraph |
Khmer (Cambodia) | KHMER | pdfCalligraph |
Malayalam | MALAYALAM | pdfCalligraph |
Odia | ORIYA | pdfCalligraph |
Tamil | TAMIL | pdfCalligraph |
Telugu (Dravidian language) | TELUGU | pdfCalligraph |
Thai | THAI | pdfCalligraph |
Chinese | Core | |
Japanese | Core | |
Korean | Core | |
WESTERN | Core | |
Russian, Ukrainian, Belarussian, Bulgarian and others | CYRILLIC | Core |
Greek | GREEK | Core |
Armenian | ARMENIAN | Core |
Georgian | GEORGIAN | Core |
How it works
For this example, we'll demonstrate using pdfCalligraph to correctly render text in different languages. First, let’s start with a simple English sentence, which we've translated into three different languages using Google Translate.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
final String[] sources = {"english.xml", "arabic.xml", "hindi.xml", "tamil.xml"};
final PdfWriter writer = new PdfWriter(DEST);
final PdfDocument pdfDocument = new PdfDocument(writer);
final Document document = new Document(pdfDocument);
final FontSet set = new FontSet();
set.addFont("fonts/NotoNaskhArabic-Regular.ttf");
set.addFont("fonts/NotoSansTamil-Regular.ttf");
set.addFont("fonts/FreeSans.ttf");
document.setFontProvider(new FontProvider(set));
document.setProperty(Property.FONT, new String[]{"MyFontFamilyName"});
for (final String source : sources) {
final File xmlFile = new File(source);
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final org.w3c.dom.Document doc = builder.parse(xmlFile);
final Node element = doc.getElementsByTagName("text").item(0);
final Paragraph paragraph = new Paragraph();
final Node textDirectionElement = element.getAttributes().getNamedItem("direction");
boolean rtl = textDirectionElement != null && textDirectionElement.getTextContent()
.equalsIgnoreCase("rtl");
if (rtl) {
paragraph.setTextAlignment(TextAlignment.RIGHT);
}
paragraph.add(element.getTextContent());
document.add(paragraph);
}
document.close();
pdfDocument.close();
writer.close();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
string[] sources = new string[] { "english.xml", "arabic.xml", "hindi.xml", "tamil.xml" };
PdfWriter writer = new PdfWriter(DEST);
PdfDocument pdfDocument = new PdfDocument(writer);
Document document = new Document(pdfDocument);
FontSet set = new FontSet();
set.AddFont("NotoNaskhArabic-Regular.ttf");
set.AddFont("NotoSansTamil-Regular.ttf");
set.AddFont("FreeSans.ttf");
document.SetFontProvider(new FontProvider(set));
document.SetProperty(Property.FONT, new String[] { "MyFontFamilyName" });
foreach (string source in sources)
{
XmlDocument doc = new XmlDocument();
var stream = new FileStream(source, FileMode.Open);
doc.Load(stream);
XmlNode element = doc.GetElementsByTagName("text").Item(0);
Paragraph paragraph = new Paragraph();
XmlNode textDirectionElement = element.Attributes.GetNamedItem("direction");
Boolean rtl = textDirectionElement != null && textDirectionElement.InnerText.Equals("rtl");
if (rtl)
{
paragraph.SetTextAlignment(TextAlignment.RIGHT);
}
paragraph.Add(element.InnerText);
document.Add(paragraph);
}
document.Close();
Input
Output
Resources
Here you will find the needed resources to install and use pdfCalligraph.
Other resources
iText 7 pdfCalligraphのコア機能
既製のPDFクリエイターでは、インド語派のデーヴァナーガリーのような文字のやり取りや書記体系、及びテキストの分割が難しい複合テキストで問題が発生し、テキストの抽出が困難です。pdfCalligraphであれば可能です。
高度なフォント機能を活用
OpenType機能、カーニング、合字やグリフの代替などが使えます。
透明性のあるサポートは多言語に対応
ブラーフミー系文字、アラビア語、ヘブライ語のスクリプトを使っている言語を含みます。
言語や筆記体系を自動検出
必要なフォント機能が有効になり、自動的に適用されます。手動設定が可能です。pdfCalligraphは、iText 7 CoreおよびpdfHTMLとシームレスに統合します。
あらゆる筆記体系のタイポグラフィを調整
左寄せ、右寄せ、中央揃え、両端揃えができます。
iText 7 pdfCalligraphを使う理由
自動一括処理の場合、 PDF文書は通常、基本的なフォントに依存していました。つまり、フォント機能、テキストが重なる複雑な書記体系、スクリプト関数、またはアラビア語、タミル語、カンナダ語みたいなテキストの並び替えが必要な言語などの高度なタイポグラフィ機能が使用できないということです。 pdfCalligraphはそれを可能としており世界中のあらゆる地域に貴社のサービスを提供することができるようにしました。
国際事業のサポート
PDFのプログラミングを調整することなく、多言語向けの文書処理を使用することができます。多文化ユーザー間で独自仕様ではないデータ形式をやり取りできます。さまざまな書記体系でPDF文書を大量に作成できます。
特殊言語を持つPDFへの巧妙な変換
カンナダ語、 アラビア語、タミル語など、複数の言語にある特殊なフォントや文字をPDFで 利用できます。
PDFにある書記体系の自動検出
PDF作成時に使用されている書記体系を検出します。 スクリプト 固有の情報やフォント固有の情報に基づいてグリフの置換を行います。右から左へと読むアラビア語などは、読み順に関する情報を追加します。