Skip to content

Fix for Issue #1430: API to set custom first-line baseline Y in ColumnText#1477

Merged
andreasrosdal merged 5 commits intomasterfrom
copilot/fix-null-pointer-issue
Feb 16, 2026
Merged

Fix for Issue #1430: API to set custom first-line baseline Y in ColumnText#1477
andreasrosdal merged 5 commits intomasterfrom
copilot/fix-null-pointer-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Fix for Issue #1430: API to set custom first-line baseline Y in ColumnText

Plan:

  • Understand the issue: Users want explicit control over first line baseline Y position
  • Review ColumnText.java implementation to understand current leading/yLine behavior
  • Add new field customFirstLineBaselineY to store custom first line baseline
  • Add setter method setFirstLineBaselineY(float baselineY) to set custom baseline
  • Modify go() method to use custom baseline when set (instead of yLine - leading)
  • Add getter method getFirstLineBaselineY() to retrieve custom baseline
  • Add clear method clearFirstLineBaselineY() to reset to default behavior
  • Update copy constructor to include custom baseline field
  • Create comprehensive test to validate the new functionality
  • Run existing tests to ensure no regression
  • Create example demonstrating the new API
  • Create test for exact issue scenario
  • Request code review and security scan
  • All checks passed successfully

Implementation Summary:

This PR addresses issue #1430 by adding a new API to ColumnText that allows users to explicitly set the baseline Y position for the first line without needing to manually calculate yLine from the desired baseline and leading.

New API Methods:

  • setFirstLineBaselineY(float baselineY) - Sets custom baseline Y for the first line
  • getFirstLineBaselineY() - Gets the custom baseline Y (or NaN if not set)
  • clearFirstLineBaselineY() - Clears the custom setting

Key Features:

  1. Takes precedence over normal yLine - leading calculation
  2. Only affects the first line; subsequent lines use normal leading
  3. Works with both addText() and addElement() usage
  4. Compatible with existing setUseAscender and setAdjustFirstLine flags
  5. Validates baseline is within column bounds

Changes Made:

  • ColumnText.java: Added customFirstLineBaselineY field and three new methods
  • ColumnTextFirstLineBaselineTest.java: Comprehensive test suite (8 tests)
  • FirstLineBaselineExample.java: Example demonstrating the new API
  • Issue1430Test.java: Test cases matching the exact issue scenario

Test Results:

✅ All 10 new tests passing (8 + 2)
✅ All existing ColumnText tests passing (13 total)
✅ Code review: No issues found
✅ Security scan: No vulnerabilities detected
✅ Generated sample PDFs demonstrating the solution


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@andreasrosdal andreasrosdal changed the title [WIP] Fix null pointer exception in PDF processing Fix for Issue #1430: API to set custom first-line baseline Y in ColumnText Feb 16, 2026
Copilot AI and others added 4 commits February 16, 2026 11:08
…positioning

Co-authored-by: andreasrosdal <259156774+andreasrosdal@users.noreply.github.com>
Co-authored-by: andreasrosdal <259156774+andreasrosdal@users.noreply.github.com>
Co-authored-by: andreasrosdal <259156774+andreasrosdal@users.noreply.github.com>
@andreasrosdal andreasrosdal marked this pull request as ready for review February 16, 2026 11:11
@andreasrosdal andreasrosdal merged commit 02a4c79 into master Feb 16, 2026
1 check failed
@andreasrosdal andreasrosdal deleted the copilot/fix-null-pointer-issue branch February 16, 2026 11:11
Copilot AI requested a review from andreasrosdal February 16, 2026 11:11
Copilot stopped work on behalf of andreasrosdal due to an error February 16, 2026 11:11
@sonarqubecloud
Copy link

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.

2 participants