pylatex Command

I'm using pylatex and I need to attach a logo in the header.

I want to use this latex example:

\documentclass{article}
\usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{xcolor}
\pagestyle{fancy}
\begin{document}
SOMETHING
\end{document}


I tried with this:

import pylatex as pyl
arguments=NoEscape(r'\begin{picture}(0,0) \put(0,0){\includegraphics[width=4cm]{logo}} \end{picture}')).dumps()


But is does not work. I do not get an error, it simly does not include it in the tex file. Thank you

The .dumps() function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append with the command itself as argument (and not the dump).

MWE:

import pylatex as pyl

doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))

doc.preamble.append(pyl.Command('pagestyle', 'fancy'))

doc.append('abc')



Result (.tex):

\documentclass{article}%
\usepackage[T1]{fontenc}%
\usepackage[utf8]{inputenc}%
\usepackage{lmodern}%
\usepackage{textcomp}%
\usepackage{lastpage}%
\usepackage{graphicx}%
\usepackage{fancyhdr}%
%
\pagestyle{fancy}%

Result (.pdf):