Another method, compile it with pdflatex --shell-escape filename.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{dummy.tex}
\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-6.5,-4)(6.5,7.5)
\psaxes[trigLabelBase=2,dx=\psPiH,xunit=\psPi,trigLabels]%
{->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]
\psset{algebraic=true}
\psplot[yMaxValue=6,yMinValue=-3,linewidth=1.6pt,plotpoints=2000,
linecolor=red]{-4.55}{4.55}{tan(x)}
\end{pspicture}
\end{document}
\end{filecontents*}
\usepackage{graphicx}
\def\GetImage#1{%
\immediate\write18{latex dummy}%
\immediate\write18{dvips dummy}%
\immediate\write18{ps2pdf dummy.ps}%
\includegraphics[scale=#1]{dummy}%
}
\begin{document}
\noindent
\fbox{\GetImage{1}}
\end{document}