none
Localreport render EMF image dpi settings RRS feed

  • Question

  • Hi folks,

    I am working on a project in which a localreport (VS2005) should be tiffed.
    I render the report to an EMF outputformat and then save the streams as a tiff image.
    If the report is multiple pages long, I get multiple streams and multiple tiff images. So far so good.
    The resolution however is too low. Text in the saved report tiff is kinda blurry.

    ==> How can I get a higher resolution in the rendered EMF?


    I have tried to specify the dpi in the DeviceInfo, but whatever specified, it is always 96dpi.

    If I change the outputformat to TIFF, then the DpiX and DpiY settings do work... but then I encounter another problem. In the TIFF outputformat case, I get only 1 stream back, even if my report is more than 1 page long. This results a tiff file containing only the first page...

    Thanks for your help!
    Lieven.

    Code Snippet

    public void CreateTiffedReport()

    {

    LocalReport report = new LocalReport();

    report.ReportEmbeddedResource = "myReport.rdlc";

    report.DataSources.Add(new ReportDataSource("dsName", dsValue));

    ExportTiff(report);

    }


    private void ExportTiff(LocalReport report)
    {
        // dpix and dpiy don't seem to work, always 96 :(
        string deviceInfo =
              "<DeviceInfo>" +
              "  <OutputFormat>EMF</OutputFormat>" +
              "  <PageWidth>8.5in</PageWidth>" +
              "  <PageHeight>11in</PageHeight>" +
              "  <DpiX>200</DpiX>" +
              "  <DpiY>200</DpiY>" +
              "  <MarginTop>0.25in</MarginTop>" +
              "  <MarginLeft>0.25in</MarginLeft>" +
              "  <MarginRight>0.25in</MarginRight>" +
              "  <MarginBottom>0.25in</MarginBottom>" +
              "</DeviceInfo>";

        Warning[] warnings;
        _renderedReportStreams = new List<Stream>();
        report.Render("Image", deviceInfo, CreateStream, out warnings);

        foreach (Stream stream in _renderedReportStreams)
        {
            stream.Position = 0;
            Metafile image = new Metafile(stream);
            image.Save("testReport.tif", ImageFormat.Tiff);
            _reportCurrentPageIndex++;
        }
    }


    private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
    {
        Stream stream = new MemoryStream();
        _renderedReportStreams.Add(stream);
        return stream;
    }


    Thursday, May 8, 2008 8:54 AM

All replies

  • I initially thought you should set the StartPage settings to zero, but then I grabbed your code and tried it and I think the difference between yours and mine is I set the OutputFormat to TIFF instead of EMF since that is what you want to end up with anyway.  It generates just fine with multiple pages.

    http://msdn.microsoft.com/en-us/library/ms155373.aspx


    If it aint broke don't fix it


    Thursday, October 2, 2014 4:59 PM