I tried to create a document with only one paragraph, with only one word underlined.
Everything is fine, but if the paragraph is long and justified a double underline appears.
The second one is at the bottom of the page.
If I remove the justified the second underline does not appear.
var myDoc = new Document();
var myPage = myDoc.Pages.Add();
var myFont = FontRepository.FindFont("Arial Narrow", FontStyles.Regular);
var myParagraph = new TextParagraph {
HorizontalAlignment = HorizontalAlignment.Justify, // If I remove the justified the second underline does not appear
};
myParagraph.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.ByWords;
myParagraph.Position = new Position(20, 100);
var builder = new TextBuilder(myPage);
builder.AppendParagraph(myParagraph);
var myTextFragment = new Aspose.Pdf.Text.TextFragment("normal text ");
myTextFragment.TextState.FontSize = 10;
myTextFragment.TextState.Font = myFont;
myTextFragment.TextState.Underline = false; // underline;
TextSegment myTextSegment;
// Add Underline text
myTextSegment = new TextSegment(" Underline text ");
myTextSegment.TextState.Underline = true; // underline;
myTextSegment.TextState.Font = myFont;
myTextFragment.Segments.Add(myTextSegment);
// Add a long text
myTextSegment = new TextSegment(" Then a long text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"
+ " ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"
+ " commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
);
myTextSegment.TextState.Font = myFont;
myTextFragment.Segments.Add(myTextSegment);
myParagraph.AppendLine(myTextFragment);
myDoc.Pages.Add(); // adding a page for best view the secon underline.
var pdfName = "C:\temp\sampleAspose.pdf"
myDoc.Save(pdfName);