We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Wrong wrapping table-cell in a RTF

Dear Sir or Madam,

We develop an winform software and we need to generate a pdf report with different sections. One of them came from a RTF text, that it has previosly loaded from a RichEditControl.

we use a exaple code, it works for almost all cases, but it does not work when we want to print a table with a large cell text (from RTF).
When we have a many-line cell in a table, the text does not wrap properly and the border is from a single line cell (it attach text out site of the cell).
I have tried to find a solution to this bug but I have not find solution as long as all code is behind syncfusion libraries.

Our code is
Private Shared Sub PintarLinea(doc As PdfDocument, ByRef pointY As Integer, texto As String)             
      Dim page As PdfPage = doc.Pages(doc.Pages.Count - 1)
      Dim bounds As SizeF = page.GetClientSize()
      Dim metafile As PdfMetafile = DirectCast(PdfImage.FromRtf(texto, bounds.Width - 30, PdfImageType.Metafile), PdfMetafile)
      Dim format As New PdfMetafileLayoutFormat()
      IncrementarPointY(metafile.Draw(page, 30, pointY, format), doc, pointY)
end Sub

Private Shared Sub IncrementarPointY(ByRef layout As PdfLayoutResult, doc As PdfDocument, ByRef pointY As Integer)
        If (layout.Bounds.Bottom > 710) Then
            pointY = 20.0F
            pointY = layout.Bounds.Bottom + 20.0F
        End If
  End Sub

The RTF text in this case is:

I attach a zip file with the right table (docx) and how it is show (PDF).

Please, let me know if you need more information about it.

Yours sincerely,

Attachment: TableRTF_4f776c46.zip

1 Reply

KC Karthikeyan Chandrasekar Syncfusion Team November 9, 2018 11:26 AM UTC

Hi Carlos,
Thank you for contacting Syncfusion support.
Essential PDF has native support for converting RTF to PDF and it has some limitation with wrapping text. We suggest to use RTF file to PDF conversion using essential DocIO.

Kindly refer the below KB to convert the RTF to PDF.
RTF to PDF: https://www.syncfusion.com/kb/2631/how-to-convert-rtf-file-to-pdf-using-essential-docio

In order to wrap the text in PDF, please specifies the width parameter of PdfImage.FromRtf method. (i.e. PdfImage.FromRtf(“text”,width, PdfImageType.Metafile)). In PDF the text will preserved as like the metafile image.

Please try our suggestion and let us know if you need further assistance in this.

Live Chat Icon For mobile
Up arrow icon