From afa18b4472ae75e2bc238459dc5e63dbf1e3d00a Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Wed, 21 Jan 2026 21:51:07 -0500 Subject: [PATCH] jobsets: fix PDF background output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jobset PDF backgrounds were drawn from (0,0) and ignored the plotter’s offset, so the fill didn’t line up with the plotted content. Use the plotter’s page size plus its plot offset when drawing the background rectangle. This makes jobset output match the manual UI plot without changing other plot behavior. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/22793 --- pcbnew/plot_board_layers.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 8387f206e7..570ba4b1f8 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1214,18 +1214,20 @@ static void FillNegativeKnockout( PLOTTER *aPlotter, const BOX2I &aBbbox ) static void plotPdfBackground( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, PLOTTER* aPlotter ) { + const PAGE_INFO& pageInfo = aPlotter->PageSettings(); + const VECTOR2I plotOffset = aPlotter->GetPlotOffsetUserUnits(); + const VECTOR2I pageSizeIU( pageInfo.GetWidthIU( pcbIUScale.IU_PER_MILS ), + pageInfo.GetHeightIU( pcbIUScale.IU_PER_MILS ) ); + if( aPlotter->GetColorMode() && aPlotOpts->GetPDFBackgroundColor() != COLOR4D::UNSPECIFIED ) { aPlotter->SetColor( aPlotOpts->GetPDFBackgroundColor() ); - // Use page size selected in pcb to know the schematic bg area - const PAGE_INFO& actualPage = aBoard->GetPageSettings(); + // Use plotter page size and offset so background matches the plotted output. + VECTOR2I end = plotOffset + pageSizeIU; - VECTOR2I end( actualPage.GetWidthIU( pcbIUScale.IU_PER_MILS ), - actualPage.GetHeightIU( pcbIUScale.IU_PER_MILS ) ); - - aPlotter->Rect( VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); + aPlotter->Rect( plotOffset, end, FILL_T::FILLED_SHAPE, 1.0 ); } }