Sign In  Sign Up Live-Chat

Justify Textlines

Last post 07-04-2008, 11:31 AM by alexey.noskov. 5 replies.
Sort Posts: Previous Next
  •  07-04-2008, 9:33 AM 134371

    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!

     
  •  07-04-2008, 10:03 AM 134381 in reply to 134371

    Re: Justify Textlines

    Hi

     

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

    http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.paragraphalignment.html

     

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

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  07-04-2008, 10:30 AM 134388 in reply to 134381

    Re: Justify Textlines

    Attachment: Present (inaccessible)

    This is my xml-file snippet converted to pdf:

            <object type="text" rect="180,990,680,48" style="s4" name="text">
              <span style="s3">Wer seinen Urlaub in der Ferne </span>
            </object>
            <object type="text" rect="180,1040,680,48" style="s4" name="text">
              <span style="s3">verbringen will, sollte vor der </span>
            </object>
            <object type="text" rect="180,1090,680,48" style="s4" name="text">
              <span style="s3">Reise seinen Versicherungs-</span>
            </object>
            <object type="text" rect="180,1140,680,48" style="s4" name="text">
              <span style="s3">schutz überprüfen. Gerade eine </span>
            </object>

    -------------------------------------------------------------------------------------------

    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.AppendChild(run);

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

    par.ParagraphFormat.LeftIndent = 0;

    par.ParagraphFormat.RightIndent = 0;

    par.ParagraphFormat.Alignment = ParagraphAlignment.Justify;

    textBox.AppendChild(par);

    doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);

    builder.MoveTo(par);//textBox.FirstParagraph.FirstChild);

    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?


     

     

     
  •  07-04-2008, 10:49 AM 134389 in reply to 134388

    Re: Justify Textlines

    Attachment: Present (inaccessible)

    Hi

     

    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:

    http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry133970.aspx

    http://www.aspose.com/community/files/51/file-format-components/aspose.pdf/entry133741.aspx

     

    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.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  07-04-2008, 11:01 AM 134392 in reply to 134389

    Re: Justify Textlines

    hi,

    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)!

     

     

     
  •  07-04-2008, 11:31 AM 134394 in reply to 134392

    Re: Justify Textlines

    Hi

     

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

     

    Document doc = new Document();

    DocumentBuilder builder = new DocumentBuilder(doc);

    doc.FirstSection.PageSetup.TextColumns.SetCount(3);

    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.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML