locked
How to render EMF format using ReportViewer Control I am getting Error RRS feed

  • Question

  • Hi ,

    I have tried using ReportViewer Control to render it in EMF Format.

    using following Code

     

    Warning[] warnings;

    string[] streamids;

    string mimeType;

    string encoding;

    string extension;

    string deviceInfo;

    DateTime l_dtmStartDateTime = new DateTime();

    l_dtmStartDateTime = DateTime.Now;

    deviceInfo = "<DeviceInfo><OutputFormat>emf</OutputFormat><StartPage>1</StartPage></DeviceInfo>";

    byte[] bytes = rvwMain.ServerReport.Render(

    "emf", deviceInfo, out mimeType, out encoding, out extension,

    out streamids, out warnings);

    long PageCount = streamids.Length;

    long TotPages = rvwMain.ServerReport.GetTotalPages();

    long l_lngStmTotPages = streamids.Length;

    TimeSpan l_tsDuration = DateTime.Now.Subtract(l_dtmStartDateTime);

    string l_strDuration = l_tsDuration.TotalMilliseconds.ToString();

     

    I get NO error If I use any of the following Extensions

    XML, NULL, CSV (Fastest), IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC

     

    But when I try to render it using EMF I start getting following Error.

     

    ERROR MESSAGE

    System.Exception: ReportViewer.LoadReport::Microsoft.Reporting.WebForms.ReportServerException: An attempt has been made to use a rendering extension that is not registered for this report server. (rsRenderingExtensionNotFound)

     

    I am using web application to run this sample.

     

    I have read at following web site that If I render it as EMF then it will only render first page. and then I could use steamid.length to get the total pages.

    http://blogs.msdn.com/bryanke/articles/71491.aspx

     

    I actually wanted to get the total page count without effecting the application performance.

     

    Your feed back in this repect is highly appreciated!

     

    Thanks,

     

    Anthony Desa

    Friday, March 30, 2007 3:43 PM

Answers

  • I think you need "Image" as the first parameter to the Render method. EMF is already in the device info. When I do this the mime type comes out as "image/emf" and I can render the first page into a bitmap for printing, which works using some old code I have that expects EMF. Once the render has occurred the GetTotalPages property of the report is populated, though there's a warning in the manual about it being 'virtual pages' not physical pages - don't know what this means though, as it gives the correct answer in the project I'm working on.

    I was searching for how to get subsequent pages, and I think your example has the clues I need, so thanks for that!


    Wednesday, April 4, 2007 3:52 PM