How to name a pdfreport file name outside of "code section"

Hi,
I asked this back in 2017 but now I need to ask again.

I know that I can enter $pdf->Output(‘D’, ‘report.pdf’); in the code section, BUT if I do that I will lose the visual settings, which have become very handy and I do not wish that to happen.

Is there a way to do it in an event, or better a setting?

Thanks
Tony