We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Justify Textlines

i try to describe my problem.

we want to convert documents from xml to word-format. The text comes in seperate textlines and we want to add the textlines to a textcolumn in word. But the Aligmnent of textlines must be justified and fixed (not wrapped by word-processor). Is it possible to prevent auto-wrapping textlines while it is justified.

In ohter words: is it possible to align textlines justified w/o automatic word-wrapping by word?

Hope you understand, sorry for my english!

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can set paragraph alignment to be “Justify”. Please see the following link for more information.


Could you also please attach your source document? Also please create document that will show how the output document should looks like.

Best regards.

This is my xml-file snippet converted to pdf:

Wer seinen Urlaub in der Ferne

verbringen will, sollte vor der

Reise seinen Versicherungs-

schutz überprüfen. Gerade eine


This is my samplesnippet (simplified!):

Aspose.Words.Drawing.Shape textBox = new Aspose.Words.Drawing.Shape(doc, Aspose.Words.Drawing.ShapeType.TextBox);

textBox.Width = Aspose.Words.ConvertUtil.PixelToPoint(600, 300);

textBox.Height = 150;

textBox.Top = 50;

textBox.Left = 50;

textBox.DistanceLeft = 0;

textBox.DistanceTop = 0;

textBox.DistanceRight = 0;

textBox.DistanceBottom = 0;

textBox.TextBox.InternalMarginLeft = 0;

textBox.TextBox.InternalMarginLeft = 0;

textBox.TextBox.InternalMarginRight = 0;

textBox.TextBox.InternalMarginTop = 0;

Run run = new Run(doc);

Paragraph par = new Paragraph(doc);


par.ParagraphFormat.LineSpacing = Aspose.Words.ConvertUtil.PixelToPoint(48, 120);

par.ParagraphFormat.LeftIndent = 0;

par.ParagraphFormat.RightIndent = 0;

par.ParagraphFormat.Alignment = ParagraphAlignment.Justify;




builder.Font.Scaling = 100;

builder.Font.Name = "verdana";

builder.Font.Size = 9.75f;

builder.ParagraphFormat.LineSpacing = Aspose.Words.ConvertUtil.PixelToPoint(70, 300);

builder.Write("Wer seinen Urlaub in der Ferne ");//<-- i try to use Writeln() but then justify neither work!!!

builder.Write("verbringen will, sollte vor der ");

builder.Write("Reise seinen Versicherungs-");

doc.Save("document.doc", SaveFormat.Doc);


in the attachement you can compare my pdf with the word-doc. As you can see the wordwrapping in the doc is different to my PDF textlines. How can get an exact text-layout?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I tried to convert your document to PDF using the latest version of Aspose.Words and Aspose.Pdf and result looks fine (see the attached PDF document.) You can download the latest versions of Aspose.Words and Aspose.Pdf from here:



Also note that PDF and DOC formats have many differences. And it is impossible to get exactly same layout after converting DOC to PDF.

Best regards.


no this is not what i want. i must create the same worddoc-result as a existing pdf (converted from an xml) not backwards!

Our customer has an existing xml-/ and pdf-file and want to get it's equivalent word-doc!

The Problem is the text-aligmnent to justify where word wraps the text different than the textlines in our xml-file (see my sample)!

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Maybe you can try using the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);


doc.FirstSection.PageSetup.LeftMargin = 30;

doc.FirstSection.PageSetup.RightMargin = 30;

for (int i = 0; i < 3; i++)


doc.FirstSection.PageSetup.TextColumns[i].Width = 180;


builder.Font.Scaling = 100;

builder.Font.Name = "verdana";

builder.Font.Size = 9.75f;

builder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;

builder.ParagraphFormat.LineSpacing = ConvertUtil.PixelToPoint(70, 300);

builder.Write("Wer seinen Urlaub in der Ferne ");

builder.Write("verbringen will, sollte vor der ");

builder.Write("Reise seinen Versicherungs-");

doc.Save(@"Test276\document.doc", SaveFormat.Doc);

Best regards.