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

Free Support Forum - aspose.com

Spacing between Heading user label and heading.Textfragments

I’m using 11.1 version of Aspose.pdf. My requirement is to create a list paragraph having userlabel and text following it see attached Expected_Output.png file

I tried below code to achieve it but the text are getting wrapped at the center of the page (look at the List.pdf output). I want output similar to Expected_Output.png. Let me know can i achieve this.

Document pdfDoc = new Document();
pdfDoc.PageInfo.Width = 612.0;
pdfDoc.PageInfo.Height = 792.0;
pdfDoc.PageInfo.Margin = new Aspose.Pdf.MarginInfo();
pdfDoc.PageInfo.Margin.Left = 72;
pdfDoc.PageInfo.Margin.Right = 72;
pdfDoc.PageInfo.Margin.Top = 72;
pdfDoc.PageInfo.Margin.Bottom = 72;

Page pdfPage = pdfDoc.Pages.Add();
pdfPage.PageInfo.Width = 612.0;
pdfPage.PageInfo.Height = 792.0;
pdfPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo();
pdfPage.PageInfo.Margin.Left = 72;
pdfPage.PageInfo.Margin.Right = 72;
pdfPage.PageInfo.Margin.Top = 72;
pdfPage.PageInfo.Margin.Bottom = 72;

Aspose.Pdf.FloatingBox floatBox = new Aspose.Pdf.FloatingBox();
floatBox.Margin = pdfPage.PageInfo.Margin;

pdfPage.Paragraphs.Add(floatBox);
Aspose.Pdf.Text.Font font = Aspose.Pdf.Text.FontRepository.FindFont(“Arial”);

Aspose.Pdf.Heading heading = new Aspose.Pdf.Heading(1);
heading.UserLabel = “1)”;
heading.IsAutoSequence = true;
heading.Margin = new MarginInfo(10, 0, 0, 0);

TextSegment segment = new TextSegment(“the value, as of the effective date of the plan, of property to be distributed under the plan onaccount of each allowed”);
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
segment.TextState.Font.IsEmbedded = true;
heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);

heading = new Aspose.Pdf.Heading(1);
heading.IsInLineParagraph = true;
heading.Hyperlink = new WebHyperlink(“https://google.com”);
segment = new TextSegment(" hyperlink text");
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
segment.TextState.Font.IsEmbedded = true;
heading.Segments.Add(segment);


floatBox.Paragraphs.Add(heading);

heading = new Aspose.Pdf.Heading(1);
heading.IsInLineParagraph = true;
segment = new TextSegment(" Founded in 1902 as Madrid Football Club, the team has traditionally worn a white home kit since inception");
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
segment.TextState.Font.IsEmbedded = true;
heading.Segments.Add(segment);
floatBox.Paragraphs.Add(heading);


Aspose.Pdf.Heading heading2 = new Aspose.Pdf.Heading(1);
heading2.UserLabel = “a)”;
heading2.IsInList = true;
heading2.IsAutoSequence = true;
heading2.Margin = new MarginInfo(25, 0, 0, 0);
segment = new TextSegment("the value, as of the effective date of the plan, of property to be distributed ");
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
segment.TextState.Font.IsEmbedded = true;
heading2.Segments.Add(segment);


floatBox.Paragraphs.Add(heading2);

Aspose.Pdf.Heading heading3 = new Aspose.Pdf.Heading(1);
heading3.UserLabel = “i)”;
heading3.IsInList = true;
heading3.IsAutoSequence = true;
heading3.Margin = new MarginInfo(40, 0, 0, 0);
segment = new TextSegment("the value, as of the effective date of the plan, of property to be distributed ");
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
//segment.TextState.LineSpacing = 13;
segment.TextState.Font.IsEmbedded = true;
heading3.Segments.Add(segment);
floatBox.Paragraphs.Add(heading3);


Aspose.Pdf.Heading heading4 = new Aspose.Pdf.Heading(1);
heading4.UserLabel = “2)”;
heading4.IsInList = true;
heading4.IsAutoSequence = true;
heading4.Margin = new MarginInfo(10, 0, 0, 0);
segment = new TextSegment("the value, as of the effective date of the plan, of property to be distributed ");
segment.TextState.Font = font;
segment.TextState.FontSize = 10;
segment.TextState.Font.IsEmbedded = true;
heading4.Segments.Add(segment);
floatBox.Paragraphs.Add(heading4);

string outFile = @“c:\temp\List.pdf”;
pdfDoc.Save(outFile);

Hi Prashant,


Thanks for contacting support.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-40047 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

Hi Prashant,


Thanks for sharing the details.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-40115 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

The issues you have found earlier (filed as PDFNEWNET-40047) have been fixed in Aspose.Pdf for .NET 11.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)

I was hoping for a proper fix for this particular issue but output is still not coming out as expected. I can still see that the 2nd line of the heading object still does not wrap properly. 2nd line needs to wrap right below the text of 1st line, as seen in the Expected_Output.png.

When an inline object is added, text in the 2nd line is moving to the extreme left of the page.

Let me know if a new feature was added to achieve this, cause with the same code and latest dll it is still breaking.

Document pdfDoc = new Document();

pdfDoc.PageInfo.Width = 612.0;

pdfDoc.PageInfo.Height = 792.0;

pdfDoc.PageInfo.Margin = new Aspose.Pdf.MarginInfo();

pdfDoc.PageInfo.Margin.Left = 72;

pdfDoc.PageInfo.Margin.Right = 72;

pdfDoc.PageInfo.Margin.Top = 72;

pdfDoc.PageInfo.Margin.Bottom = 72;



Page pdfPage = pdfDoc.Pages.Add();

pdfPage.PageInfo.Width = 612.0;

pdfPage.PageInfo.Height = 792.0;

pdfPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo();

pdfPage.PageInfo.Margin.Left = 72;

pdfPage.PageInfo.Margin.Right = 72;

pdfPage.PageInfo.Margin.Top = 72;

pdfPage.PageInfo.Margin.Bottom = 72;



Aspose.Pdf.FloatingBox floatBox = new Aspose.Pdf.FloatingBox();

floatBox.Margin = pdfPage.PageInfo.Margin;



pdfPage.Paragraphs.Add(floatBox);

Aspose.Pdf.Text.Font font = Aspose.Pdf.Text.FontRepository.FindFont(“Arial”);



Aspose.Pdf.Heading heading = new Aspose.Pdf.Heading(1);

heading.UserLabel = "(3) ";

heading.IsAutoSequence = true;

heading.Margin = new MarginInfo(45, 0, 0, 0);

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;



TextSegment segment = new TextSegment(“Eliminate the duty of loyalty under division © of “);

segment.TextState.Font = font;

segment.TextState.FontSize = 10;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);



floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

heading.TextState.ForegroundColor = Aspose.Pdf.Color.FromArgb(0, 119, 204);

heading.Hyperlink = new WebHyperlink(“http://advance.lexis.com/api/document?collection=statutes-legislation&id=urn:contentItem:5D47-8161-6VDH-R0GH-00000-00&context=1000516”);

segment = new TextSegment(“section 1705.161 of the Revised Code”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);





floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

segment = new TextSegment(” or division (B) of “);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

heading.TextState.ForegroundColor = Aspose.Pdf.Color.FromArgb(0, 119, 204);

heading.Hyperlink = new WebHyperlink(“http://advance.lexis.com/api/document?collection=statutes-legislation&id=urn:contentItem:5D47-8161-6VDH-R0H0-00000-00&context=1000516”);

segment = new TextSegment(“section 1705.281 of the Revised Code”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

segment = new TextSegment(”, but the operating agreement may identify activities that do not violate the duty of loyalty, and all of the members or a number or percentage of members specified in the operating agreement may authorize or ratify, after full disclosure of all material facts, a specific act or transaction that otherwise would violate the duty of loyalty;”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);





heading = new Aspose.Pdf.Heading(1);

heading.UserLabel = "(4) ";

heading.IsAutoSequence = true;

heading.Margin = new MarginInfo(60, 0, 0, 0);

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;



segment = new TextSegment(“Eliminate the duty of care under division © of “);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);



floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

heading.TextState.ForegroundColor = Aspose.Pdf.Color.FromArgb(0, 119, 204);

heading.Hyperlink = new WebHyperlink(“http://advance.lexis.com/api/document?collection=statutes-legislation&id=urn:contentItem:5D47-8161-6VDH-R0GH-00000-00&context=1000516”);

segment = new TextSegment(“section 1705.161 of the Revised Code”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);





floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

segment = new TextSegment(” or division © of “);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

heading.TextState.ForegroundColor = Aspose.Pdf.Color.FromArgb(0, 119, 204);

heading.Hyperlink = new WebHyperlink(“http://advance.lexis.com/api/document?collection=statutes-legislation&id=urn:contentItem:5D47-8161-6VDH-R0H0-00000-00&context=1000516”);

segment = new TextSegment(“section 1705.281 of the Revised Code”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);



heading = new Aspose.Pdf.Heading(1);

heading.IsInLineParagraph = true;

heading.TextState.Font = font;

heading.TextState.FontSize = 10;

heading.TextState.LineSpacing = 3;

segment = new TextSegment(”, but the operating agreement may prescribe the standards by which the duty is to be measured;”);

segment.TextState.Font = font;

segment.TextState.FontSize = 12;

segment.TextState.Font.IsEmbedded = true;

heading.Segments.Add(segment);

floatBox.Paragraphs.Add(heading);



string outFile = @“c:\temp\List.pdf”;

pdfDoc.Save(outFile);

Let me know if there is any other way to achieve the output shown in Expected_Output.png. Even that would be helpful.

prashantrace:
I was hoping for a proper fix for this particular issue but output is still not coming out as expected. I can still see that the 2nd line of the heading object still does not wrap properly. 2nd line needs to wrap right below the text of 1st line, as seen in the Expected_Output.png.

When an inline object is added, text in the 2nd line is moving to the extreme left of the page.
Hi Prashant,

Thanks for contacting support.

The above stated issue is logged as PDFNEWNET-40115 in our issue tracking system and is still under investigation. Once this problem is resolved, you will be updated within this forum thread. We are sorry for this delay and inconvenience.