pstricks is not work properly

I am using pstricks package to draw a figure in pdflatex build setting, but in output pdf, the figure is missing. Here is the code.

\documentclass{article}
\usepackage[pdf]{pstricks}
\def\pdfshellescape{1}
\usepackage{auto-pst-pdf}
\usepackage{pst-all}

\begin{document}
text here

\begin{figure}
\begin{center}
\psscalebox{1.0 1.0} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-4.34)(6.54,2.14)
\psframe[linecolor=black, linewidth=0.04, dimen=outer](6.12,2.14)(0.0,-3.98)
\psframe[linecolor=black, linewidth=0.04, dimen=outer](6.54,-3.5)(5.7,-4.34)
dimen=outer](3.34,0.78)(1.3,-1.26)
fillstyle=solid,fillcolor=red, dimen=outer](2.46,-1.42)(1.46,-2.42)
\end{pspicture}
}
\end{center}
\end{figure}

\end{document}

• Did you actually run it with shell-escape enabled? That is not something you can do from with in LaTeX (for obvious reasons as being able to run arbitrary commands is a security risk) – daleif Jun 11 '20 at 15:14
• \def\pdfshellescape{1} will break all tests for whether shell escape is enabled. – David Carlisle Jul 27 '20 at 20:23

Use

\documentclass{article}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-all}
\begin{document}
[...]


and then pdflatex --shell-escape <file>

If you are a AUCTeX user, you don't need using package auto-pst-pdf. Just set the variable TeX-PDF-from-Dvi to "Dvips" and TeX-PDF-mode to 1. This can be done (for instance) with add-file-local-variable

\documentclass{article}
\usepackage[pdf]{pstricks}
%\def\pdfshellescape{1}
%\usepackage{auto-pst-pdf}
\usepackage{pst-all}

\begin{document}
text here

\begin{figure}
\begin{center}
\psscalebox{1.0 1.0} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-4.34)(6.54,2.14)
\psframe[linecolor=black, linewidth=0.04, dimen=outer](6.12,2.14)(0.0,-3.98)
\psframe[linecolor=black, linewidth=0.04, dimen=outer](6.54,-3.5)(5.7,-4.34)
dimen=outer](3.34,0.78)(1.3,-1.26)