Dear Sir,
I'm trying to render rdlc local report to pdf with itextsharp via filestream in vb.net.
and the size result of the report from itextsharp according to the rdlc report
Please guide me
Thanks
Public Class Form1
Dim folderPath As String = Application.StartupPath()
Dim selectedPath As String = "Report1.rdlc"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
reportviewer1.LocalReport.ReportPath = selectedPath
Me.reportviewer1.RefreshReport()
Me.reportviewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
reportviewer1.ZoomMode = ZoomMode.FullPage
End Sub
Public Sub ExportReport(format As String)
Dim bytes As Byte()
Dim mimeType As String = ""
Dim encoding As String = ""
Dim extension As String = ""
Dim streamIds As String() = Nothing
Dim warnings As Warning() = Nothing
' Determine the correct rendering format and file extension
Select Case format.ToUpper()
Case "PDF"
bytes = reportviewer1.LocalReport.Render(
"PDF", "<DeviceInfo><OutputFormat>PDF</OutputFormat>
<PageWidth>{pageSettings.PaperSize.Width * 100}in</PageWidth>
<PageHeight>{pageSettings.PaperSize.Height * 100}in</PageHeight>
<MarginTop>{pageSettings.Margins.Top * 100}in</MarginTop>
<MarginLeft>{pageSettings.Margins.Left * 100}in</MarginLeft>
<MarginRight>{pageSettings.Margins.Right * 100}in</MarginRight>
<MarginBottom>{pageSettings.Margins.Bottom * 100}in</MarginBottom>
</DeviceInfo>",
mimeType, encoding, extension, streamIds, warnings)
extension = "pdf"
Dim filePath As String = $"{selectedPath.Replace(".rdlc", "")}.{extension}"
File.WriteAllBytes(filePath, bytes)
Process.Start(filePath)
Case Else
MessageBox.Show("Unsupported format.")
Exit Sub
End Select
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
ExportReport("PDF")
End Sub
End Class