Hello.
I need to add a text paragraph with left and right margins. Text should be justified. Here it is my code:
Document document = new Document();
Page docPage = document.Pages.Add();
docPage.PageInfo = new PageInfo
{
Margin = new MarginInfo { Bottom = 0, Left = 0, Right = 0, Top = 0 }
};
TextFragment tf = new TextFragment("This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. This is the sample text. ");
tf.HorizontalAlignment = HorizontalAlignment.Justify;
tf.Margin = new MarginInfo(30, 0, 30, 0);
docPage.Paragraphs.Add(tf);
The result is attached. The right margin is ignored. Also the text looks ugly and does not fit the page. What did I wrong? Please advise.