Click here to Skip to main content
15,867,568 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-
VB
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()

        Try           

            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>" &
                         "</DeviceInfo>"

            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)
                'newFile.Close()

                Response.Buffer = True
                Response.Clear()
                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
                Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble())
                'Dim Text As String = System.Text.Encoding.UTF8.GetString(byteViewer)

                'Response.Write(Text)
                'Response.End()

                Response.BinaryWrite(byteViewer)
                Response.Flush()          

         
        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
Quote:
Response.BinaryWrite(byteViewer)
as it might not getting correct binary data from
Quote:
rpt.LocalReport.Render

Please help to resolve. Thanks
Posted
Updated 4-Jan-21 6:18am
Comments
[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