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.