SAP Knowledge Base Article - Public

1372993 - Text fields set next to each other overlap in the DHTML viewer for Visual Studio .NET

Symptom

  • When a text field is truncated to display less than what it actually contains, a second text field placed to the right of the first field is overlapped by the first field.
  • This works well in the Crystal Reports Designer, but overlaps in the Crystal Reports DHTML viewer.

Reproducing the Issue

  1. Create a report.
  2. Add to the designer 2 string fields with long text values.
  3. Decrease the 1st field to the point that text will be truncated (e.g.; The string will be as: "The fox jumped very high". Resize the field to "The fox jumped".
  4. Preview the report in the designer. In the CR designer preview you see "The fox jumped very", with no overlap of the text field next to it.
  5. Save Report.
  6. Display the report in a web app.
  7. The "The fox jumped very" field overlaps the text field next to it.
  • Crystal Reports 2008 SP2
  • Visual Studio .NET 2003, 2005, or 2008
  • .NET Web application

Cause

  • The .NET WebForms CrystalReportViewer requires knowledge of the client-side screen DPI to properly compose reports. 
  • When the screen resolution is set to 120 DPI, text fields will overlap.

Resolution

There are two possible solutions to the issue:

Solution 1

Set the display resolution to 96 DPI.

Solution 2

Specify the DPI value using the property CrystalReportViewer.RenderingDPI. this is done by creating a page that will determine the DPI of a client machine via HTML by measuring an object of 1 inch in height in pixels (There's no standard JavaScript that works across all browser types.):

<HTML>
<BODY>
Redirecting to viewer…
<div id="dpi" style="height: 1in; left:-100%; position: absolute; top:-100%; width: 1in"></div>
<script type="text/javascript">
//<![CDATA[
    window.location = "Viewer.aspx?dpi=" + document.getElementById("dpi").offsetHeight;
//]]>
</script>
</BODY>
</HTML>
  • The above page creates a div named "dpi" 1inch x 1 inch, and places it off the visible page. The JavaScript then redirects to the Viewer page (Viewer.aspx), where the HTTP Get parameter "dpi" is set to be equal to the 1 inch box measured in pixels.
  • Then in the Viewer.aspx page, retrieve this value and specify the DPI for the viewer:
protected void Page_Load(object sender, EventArgs e)
{
    int dpi = Convert.ToInt32(Request["dpi"];
    CrystalReportViewer1.RenderingDPI = dpi;
}
  • This is considered to be a permanent solution and there are no further fixes planned for this issue.

Keywords

KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1