Free Support Forum - aspose.com

Chinese Sentence does not wrap correctly within a Paragraph

I tried to display the following sentence within a Paragraph but it does not wrap the Chinese sentence correctly. I tried DiscretionaryHyphenation, No Wrap as well as By Words, they all look weird.
The DiscretionaryHyphenation puts a dash in almost every sentence, no wrap cut off the sentence and By Words put extra space in between characters.

Can you please help and let me know what I missed?

Aspose.Pdf.Page pdfPageBios = (Aspose.Pdf.Page)pdfDocument.Pages[pageNumber];
TextBuilder textBuilderBios = new TextBuilder(pdfPageBios);

string sampleString = “William先生現任董事總經理兼投資組合經理,亦是ABC 按揭及房地產相關機會策略的首席投資組合經理之一,掌管ABC於歐洲公共及私人按揭、房地產及專門金融市場的機會投資”;

TextFragment biosFragment = new TextFragment(sampleString);

biosParagraph.FormattingOptions.WrapMode = Aspose.Pdf.Text.TextOptions.TextFormattingOptions.WordWrapMode.DiscretionaryHyphenation;

biosFragment.TextState.Font = FontRepository.FindFont(“PMingLiU”);
biosFragment.TextState.FontStyle = FontStyles.Regular;
biosFragment.TextState.FontSize = 10;
biosFragment.TextState.LineSpacing = 6;
biosFragment.TextState.ForegroundColor = Color.Black;

// add fragment to paragraph
biosParagraph.AppendLine(biosFragment);
textBuilderBios.AppendParagraph(biosParagraph);

pdfDocument.Save(outputFilePath);

@imyt

Thanks for contacting support.

Would you please share your sample source PDF document along with current output in your environment, and expected output as well. We will test the scenario in our environment and address it accordingly.