\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}

\title{}
\author{}
\date{}

\pdfinfo{%
  /Title    ()
  /Author   ()
  /Creator  ()
  /Producer ()
  /Subject  ()
  /Keywords ()
}

% prints everything when \trimdef is not defined
\newcommand{\trimout}[1]{\ifx\trimdef\undefined#1\fi}

\begin{document}
\maketitle

% simple if else

\def\mydef{0}

\ifx\mydef\undefined
mydef is undefined
\else
mydef is defined
\fi

\ifdefined\mydef
mydef is defined2
\fi

% conditioned print command

% \def\trimdef{0}

[\trimout{print using trimout and trimdef}]

\trimout{
      \begin{figure}
        \caption{null caption}      
      \end{figure}
}

\end{document}
