In MS Word 2010 if something is justified but does not take up the entire line, it does not spread it across the screen. However, if you have text that goes across the entire page and it is justified,
it spreads across the page so that everything is in a line on the right edge so it looks neater.
We need Aspose to function like MS Word to not justify a line if it is not long enough.
Aspose version 11 and sample project attached
Thanks for your inquiry. I think, you can achieve this by using the following code snippet:
Document doc = new Document();
doc.CompatibilityOptions.DoNotExpandShiftReturn = true;
DocumentBuilder builder = new DocumentBuilder(doc);
builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
builder.InsertHtml("Lorem
ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum");
doc.Save(@"c:\test\out.docx");
Your fix almost did the trick. However, I am running into another justify problem with different text. When using the following: string html = “123 Main Street
\r\nHouston, TX 12345”;
The justify works when saved to a docx file, however, does not when saved to a pdf.
Justify works
string html = "123 Main Street \r\nHouston, TX 12345";
document.Save(wordFilepath, SaveFormat.Docx);
Justify does not work
string html = "123 Main Street\r\nHouston, TX 12345";
document.Save(wordFilepath + ".pdf", SaveFormat.Pdf);
Thanks for the additional information. While using the latest version of Aspose.Words i.e. 11.0.0, I managed to reproduce this issue on my side. This issue has already been logged in our bug tracking system. Your request has been linked to this issue and you will be notified as soon as it is resolved.