[Tex/LaTex] Caption at the side of the PDF figure in landscape orientation

captionslandscaperotating

The PDF document page I need to include in my document is in landscape orientation. How do I get the resulting output page in the PDF file on one hand shown in landscape orientation with the rotated PDF image for better visibility and on the other hand with the caption on the left side of the page and not at the bottom as my document has to be printed out in portrait orientation? Also it should remain on Page 1 and not go to the next page.

As I have a PDF figure so I tried it out with \usepackage{pdflscape}:

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{Fancy page header}
\fancyfoot[C]{Footer}
\fancyfoot[R]{\thepage}
\usepackage{kantlipsum}
\usepackage{afterpage}
\usepackage{pdflscape}

\begin{document}

\kant[1]
\afterpage{
\clearpage
\section{New Section}
\begin{landscape}
\begin{figure}[htb]
  \centering
  \rotatebox[origin=c]{-90}{
  \begin{minipage}{.5\linewidth}
  \includegraphics[scale=.9,angle=90]{example-image-a}  %% adjust angle
  \caption{Figure caption is coming here and it will be by the side of the figure}
  \end{minipage}%
  }
 \end{figure}
\end{landscape}
}
\kant
\end{document}

but the \usepackage{pdflscape} brings it to a new page and the caption is at the bottom.

This is the result I would like to have:

enter image description here

Do I have too many wishes?

I am thankful for any feedback in advance.

Best Answer

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{Fancy page header}
\fancyfoot[C]{Footer}
\fancyfoot[R]{\thepage}
\usepackage{kantlipsum}
\usepackage{afterpage}
\usepackage{pdflscape}

\begin{document}

\kant[1]
\afterpage{
\clearpage
\begin{landscape}
\begin{figure}[htb]
  \centering
  \rotatebox[origin=c]{-90}{
  \begin{minipage}{.5\linewidth}
  \includegraphics[scale=.9,angle=90]{example-image-a}  %% adjust angle
  \caption{Figure caption is coming here and it will be by the side of the figure}
  \end{minipage}%
  }
 \end{figure}
\end{landscape}
}
\kant
\end{document}

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{Fancy page header}
\fancyfoot[C]{Footer}
\fancyfoot[R]{\thepage}
\usepackage{kantlipsum}

\begin{document}
\section{This is a section}
\begin{figure}[!htb]
  \centering
  \includegraphics[scale=1.1,angle=90]{example-image-a}  %% adjust angle and scale appropriately
  \caption{Figure caption is coming here and it will be by the side of the figure}
 \end{figure}
\kant
\end{document}

enter image description here