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

Free Support Forum - aspose.com

Justify by Seagment not working

Hi,

I did the justification on pdf document but it always do the full justification but i need justification by parts means seagment or text wise justification. Do you have any ETA for this request.

Regd,

Sanjay

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

Using Aspose.pdf you can not only specify the Justification settings for the whole Pdf, but, you can also set this property for Text segements. Please try the following code snippet.

For more information Please visit Set Text Alignment

//Instantiate Pdf instance by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create a new section in the Pdf object
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Set text color to blue in the whole section
sec1.TextInfo.Color = new Aspose.Pdf.Color("Red");

//Add 1st paragraph in Left Alignment
sec1.Paragraphs.Add(new Aspose.Pdf.Text(sec1, "Left Aligned Text"));

//Create 2nd paragraph in Right Alignment
Text t1 = new Aspose.Pdf.Text(sec1);
//Create a segment "seg1" in the paragraph "t3"
Segment seg1 = new Segment(t1);
//Assign some content to the segment
seg1.Content = "Right Aligned Text";
//Set the color of the segment to red
seg1.TextInfo.Color = new Aspose.Pdf.Color("Blue");
//Add segment (with red text color) to the paragraph
t1.Segments.Add(seg1);
t1.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Right;

//Create 3rd paragraph in Center Alignment
Text t2 = new Aspose.Pdf.Text(sec1);
//Create a segment "seg1" in the paragraph "t3"
Segment seg11 = new Segment(t2);
//Assign some content to the segment
seg11.Content = "Center Aligned Text";
//Set the color of the segment to red
seg11.TextInfo.Color = new Aspose.Pdf.Color("Green");
//Add segment (with red text color) to the paragraph
t2.Segments.Add(seg11);
t2.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Center;

//Add 2nd & 3rd text paragraph to the section with overridden text format settings
sec1.Paragraphs.Add(t1);
sec1.Paragraphs.Add(t2);

// Save the Pdf file
pdf1.Save("c:/Temp/Allignment_output.pdf");

The resultant Pdf is in attachment. In case of any further issues, feel free to share.