アジアのタイポグラフィを扱う

アジアのタイポグラフィは、アジアの言語で書かれた文書のテキスト段落のオプションのセットです。

Aspose.Wordsは、ParagraphFormatクラスとそのプロパティの一部を使用したアジアのタイポグラフィをサポートします。

アジア語とラテン語のテキストまたは数字の間のスペースを自動的に調整します

東アジア語とラテン語の両方のテキストを含むテンプレートを設計していて、両方のタイプのテキスト間のスペースを制御してフォームテンプレートの外観を向上させたい場合は、これらの2つのタイプのテキスト間のスペースを自動的に調整するようにフォームテンプレートを構成できます。 これを実現するには、ParagraphFormatクラスのAddSpaceBetweenFarEastAndAlphaプロパティとAddSpaceBetweenFarEastAndDigitプロパティを使用できます。

次のコード例は、AddSpaceBetweenFarEastAndAlphaプロパティとAddSpaceBetweenFarEastAndDigitプロパティの使用方法を示しています:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set paragraph formatting properties
ParagraphFormat paragraphFormat = builder.getParagraphFormat();
paragraphFormat.setAddSpaceBetweenFarEastAndAlpha(true);
paragraphFormat.setAddSpaceBetweenFarEastAndDigit(true);
builder.writeln("Automatically adjust space between Asian and Latin text");
builder.writeln("Automatically adjust space between Asian text and numbers");
dataDir = dataDir + "DocumentBuilderSetSpacebetweenAsianandLatintext_out.doc";
doc.save(dataDir);

改行オプションの設定

Microsoft Wordの段落プロパティダイアログボックスのアジアのタイポグラフィタブには改行グループがあります。 このグループのオプションは、以下を使用して設定できます。FarEastLineBreakControl, WordWrap, HangingPunctuation ParagraphFormatクラスのプロパティ。

次のコード例は、これらのプロパティを使用する方法を示しています:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
Document doc = new Document(dataDir + "Input.docx");
ParagraphFormat format = doc.getFirstSection().getBody().getParagraphs().get(0).getParagraphFormat();
format.setFarEastLineBreakControl(false);
format.setWordWrap(true);
format.setHangingPunctuation(false);
dataDir = dataDir + "SetAsianTypographyLinebreakGroupProp_out.doc";
doc.save(dataDir);

アジアの段落の間隔とインデントを変更する

次のコード例は、アジアの段落の間隔とインデントを変更する方法を示しています:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
Document doc = new Document(dataDir + "Input.docx");
ParagraphFormat format = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat();
format.setCharacterUnitLeftIndent(10); // ParagraphFormat.LeftIndent will be updated
format.setCharacterUnitRightIndent(10); // ParagraphFormat.RightIndent will be updated
format.setCharacterUnitFirstLineIndent(20); // ParagraphFormat.FirstLineIndent will be updated
format.setLineUnitBefore(5); // ParagraphFormat.SpaceBefore will be updated
format.setLineUnitAfter(10); // ParagraphFormat.SpaceAfter will be updated
dataDir = dataDir + "ChangeAsianParagraphSpacingandIndents_out.doc";
doc.save(dataDir);