Search code examples
crystal-reportsreportingcrystal-reports-2010

World map not dispalyed in crystal reports


I'm generating a pdf report using crystal report, I would like to use Data Map Tool

In c# code I've a dataset containing geographicals fields and some values to display in the map.

    public class CrystalReportViewerPlugIn : ICrystalReportViewer
    {
      private ReportDocument _reportDocument;
      private CrystalReportViewer _crystalReportViewer;

      public void Init(string fileName, DataSet dataSet)
      {
        _reportDocument = new ReportDocument();
        _reportDocument.Load(fileName);
        _reportDocument.SetDataSource(dataSet);
        _crystalReportViewer = new CrystalReportViewer();
        _crystalReportViewer.DisplayToolbar = false;
        _crystalReportViewer.DisplayGroupTree = false;
        _crystalReportViewer.PageToTreeRatio = 4;
        _crystalReportViewer.RefreshReport();
        _crystalReportViewer.ReportSource = _reportDocument;
      }
    }

Then I export the result into a strem:

public MemoryStream GetCrystalReportResults(string rptFileName, DataSet ds)
{
  var crystalReportViewer = new CrystalReportViewerPlugIn();
  crystalReportViewer.PlugIn.Init(rptFileName, ds);
  crystalReportViewer.PlugIn.Control.Visible = true;
  var oStream = crystalReportViewer.PlugIn.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
  var byteArray = new byte[oStream.Length];
  oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
  return new MemoryStream(byteArray);
}

The stream is exported as pdf:

protected virtual IHttpActionResult FinalizeExport(MemoryStream data, string name)
{
  string contentType = "application/octet-stream";
  name = name.GetCleanFileName();

  var response = Request.CreateResponse(HttpStatusCode.OK);
  response.Content = new StreamContent(data);
  response.Content.Headers.Remove("content-type");
  response.Content.Headers.Add("content-type", contentType);
  response.Content.Headers.Remove("x-filename");
  response.Content.Headers.Add("x-filename", name);
  response.Content.Headers.Add("Content-Disposition", "inline; filename=\"" + name + "\"");
  response.Content.Headers.Add("Content-Length", data.Length.ToString());

  return ResponseMessage(response);
}

The world map is not displayed, do you have anny idea about this issue ?


Solution

  • Crystal report's map works only in 32 bits environment.