Working with Asian Typography

Asian Typography is a set of options for text paragraphs in documents written in Asian languages.

Aspose.Words supports Asian Typography using the ParagraphFormat class and some of its properties.

Automatically Adjust Space between Asian and Latin Text or Numbers

If you are designing a template with both East Asian and Latin text and want to enhance the appearance of your form template by controlling the spaces between both types of text, you can configure your form template to automatically adjust the spaces between these two types of text. To achieve this, you can use AddSpaceBetweenFarEastAndAlpha and AddSpaceBetweenFarEastAndDigit properties of the ParagraphFormat class.

The following code example shows how to use AddSpaceBetweenFarEastAndAlpha and AddSpaceBetweenFarEastAndDigit properties:

// 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);

Set Line Break Options

The Asian Typography tab of the paragraph properties dialog box in Microsoft Word has line break group. The options of this group can be set using the FarEastLineBreakControl, WordWrap, HangingPunctuation properties of the ParagraphFormat class.

The following code example shows how to use these properties:

// 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);

Change Asian Paragraph Spacing and Indents

The following code example shows how to change Asian paragraph spacing and indents:

// 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);