I have a report which I am building based on a custom markup system which is used to apply styles to text. I am currently looping through the markup and applying styles to sections based upon tags. I create a section which is to contain all of my text (which is already formatted other than font styles), then add the text to it using the following method:
Private Sub addText(Section As ISection, text As String, fontStyle As Infragistics.Documents.Reports.Graphics.Font) Dim newText As IText newText = Section.AddText() newText.Style.Font = fontStyle newText.AddContent(text) End Sub
The main problem with this is that this doesn't append the text to the end of the last line, , but instead starts a 'new line' within the report. Is there any way to add the newly styled text without starting a new line, instead appending it to the text that has already been written?
Hello Nick,
Thank you for reaching out. When using the AddContent method, include the style as one of your parameters.
eg.
newText.AddContent(text, newText.Style);
Let me know if this helps or have any additional questions.
Thank you for your response Michael. Unfortunately, this did not fix the issue for me. If I use the method suggested, I get the original formatting, but none of my styles are applied. Does the itext.addcontent with a style parameter apply that style to just the content added, or does it apply it to the entire iText object? In my case, I have a few lines which may be bolded, but when using the suggested method, it is not.
My code to attempt applying this method:
Dim iText as IText = section.AddText
For each part as string in parts
ProcessMarkupStyle(part, font)
addtext(iText, part, font)
Next
Private Sub addText(iText As IText, text As String, fontStyle As Infragistics.Documents.Reports.Graphics.Font) Dim newStyle As Style = iText.Style
newStyle.Font = fontStyle iText.AddContent(text, newStyle) End Sub