Fix table border width not applying DPI conversion when printing
Problem
Table borders were not printing at the correct width. When users set a border width in the designer (e.g., changing from 1pt to 5pt via right-click Table → Properties → Border), the borders would display correctly on screen but would always print at 1pt regardless of the specified size.
Root Cause
The issue was in RdlEngine/PageDrawing.cs where two methods (DrawLine and DrawCurve) were responsible for drawing borders during printing. Both had bugs related to DPI conversion:
-
DrawLine method: Calculated the DPI-adjusted width (
tmpW) but then created the Pen with the original, unconverted width (w) - DrawCurve method: Never applied DPI conversion at all when creating the Pen
When printing, graphics operations use pixels as the unit (GraphicsUnit.Pixel), so border widths specified in points need to be converted using the formula: (width_in_points × DpiX) / 72
Changes
Fixed both methods to properly use DPI-converted widths:
// Before (DrawLine)
float tmpW = w;
if (g.PageUnit == GraphicsUnit.Pixel)
tmpW = (tmpW * g.DpiX) / 72;
p = new Pen(c, w); // ❌ Uses unconverted width
// After (DrawLine)
float tmpW = w;
if (g.PageUnit == GraphicsUnit.Pixel)
tmpW = (tmpW * g.DpiX) / 72;
p = new Pen(c, tmpW); // ✅ Uses DPI-converted width
The same fix was applied to DrawCurve, which previously had no DPI conversion at all.
Impact
- Table borders (and other report item borders) now print at the correct width as displayed in the designer
- No breaking changes - only fixes existing broken functionality
- Changes are minimal and focused solely on the border width calculation
Testing
- ✅ RdlEngine project builds successfully with no warnings or errors
- ✅ No security vulnerabilities introduced by this change
Fixes #[issue_number]
Original prompt
This section details on the original issue you should resolve
<issue_title>Table borders are not printing as displayed in designer</issue_title> <issue_description>If the size of the border is changed it displays correctly on screen but on printout does not print the same as displayed.
ie Right click Table | Properties | Border
Change from 1pt to 5pt - still prints at 1pt. </issue_description>
Comments on the Issue (you are @copilot in this section)
Fixes majorsilence/My-FyiReporting#26
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.