Rich Text Box not appearing properly in pdf reports


#1

I have been using Aspose.pdf Developer Enterprise Subscription for a while and my client likes it very much.

Now the client has asked me to add few rich text boxes in the form level and it is stored in the database as nvarchar(1000).

This new field is appearing properly in the form level, or when I export the data into a excel document from the datagrid.

But unfortunately, when I create the PDF document, these fields are printed with tags which is not accepatable by the client.

For eg. aspose.pdf is stored in the DB as aspose.pdf . Hence it is printed as aspose.pdf in the pdf report. Client expects it be as aspose.pdf.

Could you please suggest a way to overcome this problem?

Even writing it as "aspose.pdf" would be better than displaying with the tags.

Current project is for a small part of the business, but successfull implemental of it will really bring more gloabl customers to aspose.pdf

Thanks in Advance. I'm really seeking for help.


#2

Please refer to How to Display HTML in Text and Working with Text Containing HTML Tags .


#3

thanks for the reply .But I cant find a propery ISHTMLTagSupported under TextInfo.

I'm using the following code (looping for all records ). Basically I am printing the header first (fixed columns) and looping through the records to print each row. You can suggest an alternat methade as well.

Private Sub AddRow(ByVal pdf As Pdf, ByVal tabel As Table, _

ByVal strRichTextBox As String , byval strIssue as string ......)

Dim section As Section = pdf.Sections(0)

Dim tf1 As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo

tf1.FontSize = 16

tf1.Alignment = AlignmentType.Center

Dim row1DetailTable As Row = tabel.Rows.Add()

tf1.Alignment = AlignmentType.Left

row1DetailTable.Cells.Add(strRichTextBox, tf1)

End Sub


#4

I guess you are using an old version in which the IsHtmlTagSupported property is not included. If so please update to the latest version.


#5

Thanks for the immediate reply.

I have downloaded the latest aspose.pdf.dll from

http://www.aspose.com/Downloads/Aspose.Pdf/3.1.7.0/Default.aspx

and replaced the reference to it.

Dim section As Section = pdf.Sections(0)

Dim tf1 As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo

I expect IsHtml property to be apperated under tf1 (which is pdf.textinfo) but is not coming out.

could you please help? Is this propery only available with aspose.text class?

If so, could you help convert code mentioned above to work the same way using Text class.

thanks in advance.


#6

Please refer to the example at http://www.aspose.com/wiki/default.aspx/Aspose.Pdf/TextContainingHtmlTags.html. The IsHtmlTagSupported is a property of Aspose.Pdf.Text. So you can’t set this property in the code “row1DetailTable.Cells.Add(strRichTextBox, tf1)”. This is a flaw of Aspose.Pdf. As a workaround, you can create a Text object and set the IsHtmlTagSupported property, then add it into the cell.


#7

I have tried your work aound. But I'm unable to add a text to row. See the underlined part.

Could you please help.

Private Sub AddRow(ByVal pdf As Pdf, ByVal tabel As Table, _

ByVal strRichTextBox As String , byval strIssue as string ......)

Dim section As Section = pdf.Sections(0)

Dim tf1 As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo

tf1.FontSize = 16

tf1.Alignment = AlignmentType.Center

Dim row1DetailTable As Row = tabel.Rows.Add()

Dim text As Aspose.Pdf.Text = New Aspose.Pdf.Text

text.IsHtmlTagSupported = True

row1DetailTable.Cells.Add(strRichTextBox,text )

End Sub


#8

Thanks for considering Aspose.

I found the content you want to add into table is stored in strRichTextBox, so you codes should be like this:

Private Sub AddRow(ByVal pdf As Pdf, ByVal tabel As Table, _

ByVal strRichTextBox As String , byval strIssue as string ......)

Dim section As Section = pdf.Sections(0)

Dim row1DetailTable As Row = tabel.Rows.Add()

'Following codes are modified by Kevin.Zuo

Dim cell As Cell = row1DetailTable .Cells.Add()

Dim text As Aspose.Pdf.Text = New Aspose.Pdf.Text (strRichTextBox)

text.IsHtmlTagSupported = True

text.TextInfo.FontSize = 16

text.TextInfo.Alignment = AlignmentType.Center

cell.Paragraphs.Add(text)

End Sub


#9

Thanks for the reply. I have tried the modified code.

But the statement row1DetailTable.Cells.Add(text )

is not working becasues aspose.pdf.text is not a parameter for row1DetailTable.Cells.Add

Please help

thanks in advance


#10

Dear bobby

Sorry for the mistake made before.

I just adjusted the codes above and added new two lines which are in bold.

Regards,