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

Free Support Forum - aspose.com

Inline paragraph alignment bug

Hello.


There is the requirement to create a text paragraph with a hyperlink in the middle aligned to the right. In PDF Generator it was possible to assign a hyperlink to a text segment, but in your new API it can be assigned to a TextFragment only. So what we do to create a paragraph is add some text fragments with IsInLineParagraph = true and assign a hyperlink to one of them. Here it is the sample code:

private static void Main()
{
Document doc = new Document();
Page p = doc.Pages.Add();

p.Paragraphs.Add(Create(false, false));
p.Paragraphs.Add(Create(true, false));
p.Paragraphs.Add(Create(true, true)); // the link
p.Paragraphs.Add(Create(true, false));

doc.Save(@“d:\wrong_inline_paragraph.pdf”);
}

private static TextFragment Create(bool inInline, bool isLink)
{
TextFragment tf = new TextFragment(“A B C”)
{
IsInLineParagraph = inInline
};

tf.TextState.HorizontalAlignment = HorizontalAlignment.Right;

if (isLink)
{
tf.Hyperlink = new WebHyperlink(“www.google.com”);
tf.TextState.ForegroundColor = Color.Blue;
tf.TextState.FontStyle = FontStyles.Italic;
}
return tf;
}

The expected result is 1 paragraph aligned to the right with the hyperlink, however we’ve got the document with several issues (attached):

1) Every fragment begins from a new line despite the fact that it is an inline fragment;
2) The first letter (A) in some paragraphs is missed

The output will be expected if the alignment is either Left or Justify and will be wrong if it’s either Right or Center.

Please advise how to get the required output.
1) As I mentioned above we could set a hyperlink to a segment in PdfGenerator, but in your current approach where it can be set to a TextFragment is very inconvenient when a link should be in the center of a paragraph.
Probably we do not know all details and my question is if it's possible to assign a hyperlink to a segment somehow ? or I'd like to know the efficient way of a paragraph creation with a link in the middle.

2) We noticed in the release notes to the version v. 10.2. that the improvement is fixed (http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/entry611655.aspx):
...
PDFNEWNET-38117 TextSegment should support hyperlink property
...
But cannot find the property in in the latest 10,7 version. Please comment.
Hi Dmitry,

ShmelP:
Hello.

There is the requirement to create a text paragraph with a hyperlink in the middle aligned to the right. In PDF Generator it was possible to assign a hyperlink to a text segment, but in your new API it can be assigned to a TextFragment only. So what we do to create a paragraph is add some text fragments with IsInLineParagraph = true and assign a hyperlink to one of them. Here it is the sample code:

private static void Main()
{
Document doc = new Document();
Page p = doc.Pages.Add();

p.Paragraphs.Add(Create(false, false));
p.Paragraphs.Add(Create(true, false));
p.Paragraphs.Add(Create(true, true)); // the link
p.Paragraphs.Add(Create(true, false));

doc.Save(@"d:\wrong_inline_paragraph.pdf");
}

private static TextFragment Create(bool inInline, bool isLink)
{
TextFragment tf = new TextFragment("A B C")
{
IsInLineParagraph = inInline
};

tf.TextState.HorizontalAlignment = HorizontalAlignment.Right;

if (isLink)
{
tf.Hyperlink = new WebHyperlink("www.google.com");
tf.TextState.ForegroundColor = Color.Blue;
tf.TextState.FontStyle = FontStyles.Italic;
}
return tf;
}

The expected result is 1 paragraph aligned to the right with the hyperlink, however we've got the document with several issues (attached):

1) Every fragment begins from a new line despite the fact that it is an inline fragment;
2) The first letter (A) in some paragraphs is missed

The output will be expected if the alignment is either Left or Justify and will be wrong if it's either Right or Center.

Please advise how to get the required output.

Thanks for your inquiry. We have tested the scenario and noticed the inline TextFragments right alignment issues, so we have logged a ticket PDFNEWNET-39322 in our issue tracking system for further investigation. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,
Hi Dmitry,

ShmelP:

1) As I mentioned above we could set a hyperlink to a segment in PdfGenerator, but in your current approach where it can be set to a TextFragment is very inconvenient when a link should be in the center of a paragraph.
Probably we do not know all details and my question is if it's possible to assign a hyperlink to a segment somehow ? or I'd like to know the efficient way of a paragraph creation with a link in the middle.

Thanks for your inquiry. We have logged an enhancement ticket PDFNEWNET-39323 in our issue tracking system to add hyperlink to a TextSegment. We will notify you as soon as it is implemented.

ShmelP:

2) We noticed in the release notes to the version v. 10.2. that the improvement is fixed (http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/entry611655.aspx):
...
PDFNEWNET-38117 TextSegment should support hyperlink property
...
But cannot find the property in in the latest 10,7 version. Please comment.

Actually in this fix, it is recommended to use several TextFragments use with IsInlineParagraph property instead. However as you observed it is not working with right and center alignment. We will keep you updated about the above logged issues.

We are sorry for the inconvenience caused.

Best Regards,

Hello,


What is the ETA for the fix? Can we expect the fix in 10.9 ?

Hi Dmitry,


Thanks for your inquiry. I am afraid your reported issues are pending for investigation in the queue with other reported issues. As soon as we complete the analysis then we will be in a good position to share an ETA.

However, we have requested our Product team to complete the investigation at their earliest and share an ETA. We will notify you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

It’s not possible to create a paragraph with the hyper link in the middle. It sounds like the critical issue, doesn’t it ? Please set the priority for this item. We’re looking forward for the fix, because cannot deploy the code into the prod with your new API for more than 2 months.

Hi Dmitry,


Please note that we have logged enhancement tickets in our issue tracking system against your requirement and development team requires little time to investigate and implement the solution in new DOM. We do understand the criticallity and urgency of these issues but as requested earlier, please be patient and spare us little time.

PS, Issues are resolved in first come first serve basis as we believe its the fairest policy to all the customers.

The issues you have found earlier (filed as PDFNEWNET-39323;PDFNEWNET-39322) have been fixed in Aspose.Pdf for .NET 10.9.0.


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