Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I am having issue while exporting rdlc report containing Unicode characters to pdf. when exported the data in Thai shown as garbage as below-
it is actually

Data is showing correctly on webpage but when exported is show garbage data.

What I have tried:

This is what I've done so far-
Private Sub CreateReport(ByVal FileType As String, ByVal selectedFile As String, ByVal reportName As String)

        Dim warnings As Warning() = Nothing
        Dim streamids As String() = Nothing
        Dim mimeType As String = Nothing
        Dim encoding As String = Nothing
        Dim extension As String = Nothing
        Dim deviceinfo As String = Nothing
        Dim viewer As New Microsoft.Reporting.WebForms.ReportViewer()


            deviceinfo = "<DeviceInfo>" &
                         "<OutputFormat>" & FileType & "</OutputFormat>" &
                         "<PageWidth>13.15in</PageWidth>" &
                         "<PageHeight>9in</PageHeight>" &
                         "<MarginTop>0.5in</MarginTop>" &
                         "<MarginLeft>0.1in</MarginLeft>" &
                         "<MarginRight>0.1in</MarginRight>" &
                         "<MarginBottom>0.5in</MarginBottom>" &

            Dim byteViewer As Byte() = rpt.LocalReport.Render(FileType, deviceinfo, mimeType, encoding, extension, streamids, warnings)

                'Dim newFile As New FileStream(selectedFile, FileMode.Create)
                'newFile.Write(byteViewer, 0, byteViewer.Length)

                Response.Buffer = True
                Response.ContentType = mimeType

                'Response.AddHeader("content-disposition", "attachment; filename=" & hdnCustomerId.Value.ToString() & " " & reportName & " " & FinIQApp_Date.FinIQDateTime(DateTime.Now()) & ".pdf")
                Response.AddHeader("content-disposition", "attachment; filename=" & hdnCustomerId.Value.ToString() & " " & reportName & ".pdf")
                'Response.Charset = ""
                Response.ContentEncoding = System.Text.Encoding.UTF8
                'Dim Text As String = System.Text.Encoding.UTF8.GetString(byteViewer)



        Catch ex As Exception           
            LogTheException("Exception:" & ex.Message.ToString & ex.StackTrace().ToString(), ex,sSelfPath, "CreateReport")
        End Try
    End Sub

I have gone through this LocalReport.Render Method (String, String, CreateStreamCallback, out Warning[]) (Microsoft.Reporting.WebForms) | Microsoft Docs[^] and so many other links. I think issue might be in
as it might not getting correct binary data from

Please help to resolve. Thanks
Updated 4-Jan-21 6:18am
[no name] 11-Dec-20 14:28pm    
You need to specify a font "somewhere". And are you actually "exporting" or just printing (via a PDF print driver)? There's a difference.
Member 14479145 14-Dec-20 0:42am    
Hi Gerry,
Thanks for the reply. Where can I set font? I am writing file using Response.

1 solution

This thread might help you.
.net - How to embed a Font in a PDF with RDLC - Stack Overflow[^]
For reference
Exporting to a PDF File (Report Builder) - SQL Server Reporting Services (SSRS) | Microsoft Docs[^]

Hope you installed required font in that server. And it needs a restart after font installation. IISreset too.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900