<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>here is a function which does the job. It's a bit more generic,
      you have to pass the layoutname and the itemID to get the text:</p>
    <p><i>from qgis.core import *</i><i><br>
      </i><i>from qgis.gui import *</i><i><br>
      </i><i><br>
      </i><i>@qgsfunction(args='auto', group='Custom')</i><i><br>
      </i><i>def get_layout_textitem(layoutTitle, itemId, feature,
        parent):</i><i><br>
      </i><i>    """</i><i><br>
      </i><i>    Gets the text from a labelitem in the layout with the
        name layoutTitle.</i><i><br>
      </i><i>    <h2>Example usage:</h2></i><i><br>
      </i><i>    <ul></i><i><br>
      </i><i>      <li>get_layout_textitem('Layout 1', 'text1')
        -> 'lorem ipsum</li></i><i><br>
      </i><i>    </ul></i><i><br>
      </i><i>    """</i><i><br>
      </i><i><br>
      </i><i>    project = QgsProject.instance()</i><i><br>
      </i><i>    projectLayoutManager = project.layoutManager()</i><i><br>
      </i><i>    layout = projectLayoutManager.layoutByName(layoutTitle)</i><i><br>
      </i><i><br>
      </i><i>    fileNameLabel = layout.itemById(itemId)</i><i><br>
      </i><i>    fileNameText = fileNameLabel.text() </i><i><br>
      </i><i>    return fileNameText</i></p>
    <p><i><img src="cid:part1.F448A6C6.ED943DD6@wheregroup.com" alt=""></i></p>
    <div class="moz-cite-prefix">Am 04.08.2021 um 14:06 schrieb Patrick
      Dunford:<br>
    </div>
    <blockquote type="cite"
      cite="mid:f138d57d-0537-64c6-4bee-18071a88489a@gmail.com">layoutTitle
      = "Landscape 16:9 Header Nav Copyright Filename 2021" <br>
      <br>
      project = QgsProject.instance() <br>
      projectLayoutManager = project.layoutManager() <br>
      layout = projectLayoutManager.layoutByName(layoutTitle) <br>
      <br>
      fileNameLabel = layout.itemById('Filename') <br>
      fileNameText = fileNameLabel.text() </blockquote>
    <pre class="moz-signature" cols="72">-- 
Mit freundlichen Grüßen
Stefan Giese
Projektleiter/Consultant
************************************************************
Aufbau von Geodateninfrastrukturen mit Open-Source-Software 
FOSS Academy 5 Tage-Kompaktkurs „Sommerschule 2021“
Jetzt anmelden: <a class="moz-txt-link-freetext" href="https://foss-academy.com/kompaktkurse/">https://foss-academy.com/kompaktkurse/</a> 
*************************************************************
WhereGroup GmbH
Schwimmbadstr. 2
79100 Freiburg
Germany

Fon: +49 (0)761 / 519 102 - 61
Fax: +49 (0)761 / 519 102 - 11

<a class="moz-txt-link-abbreviated" href="mailto:stefan.giese@wheregroup.com">stefan.giese@wheregroup.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.wheregroup.com">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885</pre>
  </body>
</html>