or
Can someone please tell me what is incorrect with the following code. It only fails when the TIFF is one page.
Public Sub CreateProcessNotesTIFF() Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource() instanceReportSource.ReportDocument = New ProcessNotes instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo)) instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName)) Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor() 'set any deviceInfo settings if necessary Dim deviceInfo As New System.Collections.Hashtable() deviceInfo("OutputFormat") = "TIFF" deviceInfo("TiffCompression") = "ccitt4" deviceInfo("DpiX") = 300 deviceInfo("DpiY") = 300 'deviceInfo("DpiX") = 120 'deviceInfo("DpiY") = 120 'Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo) Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("IMAGE", instanceReportSource, deviceInfo) Dim fileName As String = result.DocumentName + "." + result.Extension 'Dim path As String = System.IO.Path.GetTempPath() Dim path As String = System.IO.Directory.GetCurrentDirectory() Dim filePath As String = System.IO.Path.Combine(path, fileName) Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create) fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length) End UsingEnd SubPublic Sub CreateProcessNotesTIFF() Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource() instanceReportSource.ReportDocument = New ProcessNotes instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo)) instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName)) Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor() 'set any deviceInfo settings if necessary Dim deviceInfo As New System.Collections.Hashtable() deviceInfo("OutputFormat") = "TIFF" 'deviceInfo("TiffCompression") = "ccitt4" deviceInfo("DpiX") = 300 deviceInfo("DpiY") = 300 'deviceInfo("DpiX") = 120 'deviceInfo("DpiY") = 120 'Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo) Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("IMAGE", instanceReportSource, deviceInfo) Dim fileName As String = result.DocumentName + "." + result.Extension 'Dim path As String = System.IO.Path.GetTempPath() Dim path As String = System.IO.Directory.GetCurrentDirectory() Dim filePath As String = System.IO.Path.Combine(path, fileName) Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create) fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length) End UsingEnd SubIn the sample code below is there a way to tell how many pages exported the pdf has?
Public Sub CreateProcessNotesPDF() Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource() instanceReportSource.ReportDocument = New ProcessNotes instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ProcNo", _procNo)) instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("ApplicantName", _applicantName)) Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor() 'set any deviceInfo settings if necessary Dim deviceInfo As New System.Collections.Hashtable() Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo) Dim fileName As String = result.DocumentName + "." + result.Extension 'Dim path As String = System.IO.Path.GetTempPath() Dim path As String = System.IO.Directory.GetCurrentDirectory() Dim filePath As String = System.IO.Path.Combine(path, fileName) Using fs As New System.IO.FileStream(filePath, System.IO.FileMode.Create) fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length) End UsingEnd Sub//MainReport instantiation (some code is hidden, but you should get the ideaXmlReaderSettings xmlReaderSettings = new XmlReaderSettings();xmlReaderSettings.IgnoreWhitespace = true;ReportXmlSerializer serializer = new ReportXmlSerializer();XmlReader primaryReportXmlReader = XmlReader.Create(reportDefinition.PrimaryReport.TemplateLocation, xmlReaderSettings);_primaryReport = (Telerik.Reporting.Report)serializer.Deserialize(primaryReportXmlReader);primaryReportXmlReader.Close(); SqlDataSource reportDataSource = (SqlDataSource)_primaryReport.DataSource;reportDataSource.ConnectionString = reportDefinition.ConnectionString;this._instanceReportSource.ReportDocument = _primaryReport;//We're using a custom class to define a "report definition", which contains data about sub reports,//so I'm looping through each sub report definition and instantiating it.foreach (CPSReport cpsSubReport in reportDefinition.SubReports){ XmlReader xmlReader = XmlReader.Create(cpsSubReport.TemplateLocation, xmlReaderSettings); Telerik.Reporting.Report subReportInstance = (Telerik.Reporting.Report)serializer.Deserialize(xmlReader); xmlReader.Close(); SqlDataSource subReportDataSource = (SqlDataSource)subReportInstance.DataSource; subReportDataSource.ConnectionString = reportDefinition.ConnectionString; //would be handy to automatically get from the main report //The following line is hardcoded for now because i've been experimenting. The string "subReport1" would actually be defined in our custom report definition class. Telerik.Reporting.SubReport subReport = _primaryReport.Items.Find("subReport1", true).FirstOrDefault() as Telerik.Reporting.SubReport; subReport.ReportSource = subReportInstance; //obsolete. what's the right way to do this?}