Will html to pdf.
How to aspose.words seting “Allow English text to wrap in the middle of a word” ?
Like it pdf 允許英文字元在字中換行.pdf (122.2 KB)
Please ZIP and upload your input HTML file, Aspose.Words generated PDF file showing the undesired behavior and MS Word generated PDF file showing the correct behavior here for testing. We will then investigate the issue on our end and provide you more information.
But, MS Word 2019 also does not wrap that text to next line. Please check the following MS Word 2019 generated and Aspose.Words generated PDF files:
- msw-2019.pdf (52.3 KB)
- 19.7.pdf (70.3 KB)
Aspose.Words tries to mimic the behavior of MS Word. But, you may use Aspose.HTML for .NET API to convert HTML files to PDF.
But, word2013 “Allow English text to wrap in the middle of a word”
file is it. Word2013Allow English text to wrap01 .png (159.0 KB)
and this file Word2013Allow English text to wrap02 .png (56.3 KB)
My seting
Aspose.Words.Document doc = new Aspose.Words.Document(inputStream);
doc.Sections[0].PageSetup.PaperSize = PaperSize.A4;
doc.Sections[0].PageSetup.TopMargin = 72;
doc.Sections[0].PageSetup.BottomMargin = 72;
doc.Sections[0].PageSetup.LeftMargin = 64;
doc.Sections[0].PageSetup.RightMargin = 64;
doc.UpdatePageLayout();
doc.Styles.DefaultParagraphFormat.Style.Font.NameFarEast = "標楷體";
doc.Styles.DefaultParagraphFormat.Style.Font.NameAscii = "Times New Roman";
doc.Styles.DefaultParagraphFormat.Style.Font.Kerning = -0.2;
doc.Styles.DefaultParagraphFormat.Style.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
doc.Styles.DefaultParagraphFormat.AddSpaceBetweenFarEastAndAlpha = false;
doc.Styles.DefaultParagraphFormat.AddSpaceBetweenFarEastAndDigit = false;
doc.Styles.DefaultParagraphFormat.LineSpacing = 7.5;
doc.Styles.DefaultFont.Spacing = -0.2;
doc.CompatibilityOptions.GrowAutofit = false;
doc.CompatibilityOptions.UseFELayout = true;
We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-18989. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.
@ALANFKINFO The issue has been closed as Not a Bug
. You can use the following code to generate the expected output:
// Take the margin values from registry as MS Word does it if the document's page margins are not set.
LoadOptions lo = new LoadOptions();
lo.UseSystemLcid = true;
Document doc = new Document(@"ConvertHtml2PDF_20190801.html", lo);
NodeCollection parCollection = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Node node in parCollection)
{
Paragraph para = (Paragraph)node;
// Set "Allow Latin text to wrap in the middle of a word" to True (Aspose.Words parameter has "mirrored" logic here)
para.ParagraphFormat.WordWrap = false;
// Also need to set Asian locale for paragraph break property for enable Asian Typography feature "Allow Latin text to wrap in the middle of a word".
para.ParagraphBreakFont.LocaleIdFarEast = new CultureInfo("zh-CN", false).LCID;
}
doc.Save(@"ConvertHtml2PDF_20190801.aw.pdf");
The issues you have found earlier (filed as WORDSNET-18989) have been fixed in this Aspose.Words for .NET 24.9 update also available on NuGet.