ReportExecutionService.Render multi page reports and secondary streams (2008R2)
Hello. I found the example that uses 'streamIDs' to determine the number of pages in the rendered report. However, steamIDs always returns a zero length array. The workaround to get all the pages in the report: pages = new Byte[0][]; numberOfPages = 1; byte[] currentPageStream = new byte[1] {0x00}; // put a byte to get the loop started while (currentPageStream.Length > 0) { deviceInfo = String.Format(@"<DeviceInfo>" + _deviceInfoAddl + "<StartPage>{0}</StartPage></DeviceInfo>", numberOfPages); currentPageStream = _renderEngine.Render(_renderFormat.Name, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); if (currentPageStream.Length == 0 && numberOfPages == 1) { renderException = EnumRenderException.ZERO_LENGTH_STREAM; break; } if (currentPageStream.Length > 0) { Array.Resize(ref pages, pages.Length + 1); pages[pages.Length - 1] = currentPageStream; numberOfPages++; } } numberOfPages--; My questions are: 1) is the above solution correct 2) what is the streamIDs used for ? I read somewhere that it is used to get secondary streams, what are those and how to use them? Thanks
March 24th, 2011 9:27pm

I also noticed that my proposed solution does not work with PDF format. An exception is thrown when Render is called on a page that does not exist. IMAGE simply returns a zero byte array. edit1: I got around the PDF issue with <startpage>0</startpage>, so... how can I print multipage IMAGE to Metafile?
Free Windows Admin Tool Kit Click here and download it now
March 26th, 2011 1:15am

Hi fixitchris, Generally, in order to render a report in a specified, we can use the ReportExecutionService.Render method. As an example of using this method, please refer to http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx Besides that, in rendering PDF or Image, we can also determine the number of pages by passing the DeviceInfo parameter to the ReportExecutionService.Render method. About Image Device Information Settings, please see http://msdn.microsoft.com/en-us/library/ms155373.aspx. About PDF Device Information Settings, please see http://msdn.microsoft.com/en-us/library/ms154682.aspx. In addition, the out parameter StreamIds indicates the stream identifiers which can be passed to the ReportExecutionService.RenderStream method. You can use the method to render the external resources (images, etc.) that are associated with a given report. For more information about this method, please refer to http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.renderstream.aspx Thanks, Tony Chain Tony Chain [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help
March 26th, 2011 3:13pm

Thanks for the reply Tony. Since I have not worked with secondary streams yet, the RenderStream doesn't make much sense to me yet. The main question remaining is how would I go about saving a multipage EMF using <startpage>0</startpage> where REX renders all pages at once?
Free Windows Admin Tool Kit Click here and download it now
March 26th, 2011 6:30pm

Hi fixitchris, In order to save the report in image with specified start and end page numbers, we can use the ReportExecutionService.Render method. Please first refer to the example in the link http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx. Since the example shows the code of rendering report in MHTML format, please make some changes in the code to specify the IMAGE format and start/end pages. Change string format = "MHTML"; to string format = "IMAGE"; Change string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; to string devInfo = @"<DeviceInfo><StartPage>1</StartPage>><EndPage>3</EndPage></DeviceInfo>"; Thanks, Tony ChainTony Chain [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help.
April 1st, 2011 5:02am

Hey. I thought that <startpage>0</startpage> processed all pages at once. I can render all the pages at once but I'm not sure how to write a multi page EMF. So the problem I have is more related to System.Drawing.Imaging and Metafiles. Once I have a byte[][] with multiple pages, how do I create a multipage EMF or TIFF file? edit: I actually tried calling Render with <StartPage>1</StartPage><EndPage>2</EndPage> as EMF and it only renders one page. It's like <engpage> has no effect.
Free Windows Admin Tool Kit Click here and download it now
April 2nd, 2011 11:39am

I'm still looking for a solution as well. Note--I am looking for a solution, not a link to documentation that says how things should would or what kind of objects you should be able to use. We need this to work with SSRS 2008R2. I have been looking for days and have not found a working solution, only blogs that say to try this and that, but no one that has found something that actually works. Would have been nice if the Render method could return the number of pages.
April 14th, 2011 3:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics