@@ -183,7 +183,7 @@ def process(self) -> Path | list[Path]:
183183 for variant in self .config ["variants" ]:
184184 self .log_info_subsection ('Processing variant "%s"...' , variant ["name" ])
185185 variant_config = deep_merge (self .config , variant )
186- self .log_trace (variant_config )
186+ # self.log_trace(variant_config)
187187 variant_config ["variant" ] = variant
188188 variant_config = render_config (variant_config )
189189 page_pdfs = self ._process_pages (variant_config )
@@ -201,12 +201,28 @@ def _process_pages(self, config: dict[str, Any]) -> list[Path]:
201201 self .log_debug_subsection ("Pages to process:" )
202202 self .log_debug (self .config .pages )
203203 pdf_files = []
204- for page_num , page_config in enumerate (self .config .pages , start = 1 ):
204+ for page_num , page_config_path in enumerate (self .config .pages , start = 1 ):
205+ page_name = page_config_path .stem
206+ base_config = config .copy ()
207+
208+ # If the document/variant has page-specific configuration
209+ # (a section with the same name as the page), include it
210+ if page_name in config :
211+ if "variant" in config :
212+ source_desc = f'Variant "{ config ["variant" ]["name" ]} "'
213+ else :
214+ source_desc = f'Document "{ self .config .name } "'
215+ self .log_debug_subsection (
216+ f'{ source_desc } provides settings for page "{ page_name } "'
217+ )
218+ self .log_trace (config [page_name ])
219+ base_config .update (config [page_name ])
220+
205221 page = PDFBakerPage (
206222 document = self ,
207223 page_number = page_num ,
208- base_config = config ,
209- config_path = page_config ,
224+ base_config = base_config ,
225+ config_path = page_config_path ,
210226 )
211227 pdf_files .append (page .process ())
212228
0 commit comments