Skip to content

Fix table border width not applying DPI conversion when printing#254

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-table-border-printing
Draft

Fix table border width not applying DPI conversion when printing#254
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-table-border-printing

Conversation

Copy link
Contributor

Copilot AI commented Oct 19, 2025

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:

  1. DrawLine method: Calculated the DPI-adjusted width (tmpW) but then created the Pen with the original, unconverted width (w)
  2. 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 #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.

Copilot AI changed the title [WIP] Fix table borders not printing correctly Fix table border width not applying DPI conversion when printing Oct 19, 2025
Copilot AI requested a review from majorsilence October 19, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table borders are not printing as displayed in designer

2 participants