Look at the following MWE.
\PassOptionsToPackage{export}{adjustbox}
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{graphicx}
\usepackage{adjustbox}
\newcounter{psextern}
\makeatletter
\renewcommand\FVB@VerbatimOut[1]{%
\@bsphack%
\begingroup
\FV@UseKeyValues%
\FV@DefineWhiteSpace%
\def\FV@Space{\space}%
\FV@DefineTabOut%
\def\FV@ProcessLine##1{%
\toks@{##1}\immediate\write\FV@OutFile{\the\toks@}}%
\immediate\openout\FV@OutFile #1\relax%
\WritePreamble%<<=== write preamble
\let\FV@FontScanPrep\relax
\let\@noligs\relax%
\FV@Scan}
\renewcommand\FVE@VerbatimOut{%<<=== write postamble
\WriteLine{\string\end{document}}% <<
\immediate\closeout\FV@OutFile\endgroup\@esphack}
\newcommand\WriteLine[1]{%
\begingroup%
\let\protect\@unexpandable@protect%
\edef\reserved@a{\immediate\write\FV@OutFile{#1}}%
\reserved@a%
\endgroup}
\makeatother
\newcommand\WritePreamble{%
\WriteLine{\string\documentclass[multido=false,margin=3pt]{standalone}}%
% \WriteLine{\string\input{preamble/preamble-externalb}}%
\WriteLine{\string\usepackage[T1]{fontenc}}%
\WriteLine{\string\usepackage[utf8]{inputenc}}%
\WriteLine{\string\usepackage[osf]{mathpazo}}%
\WriteLine{\string\linespread{1.05}\selectfont}%
\WriteLine{\string\usepackage[scaled=.88]{beramono}}%
\WriteLine{\string\usepackage[scaled=.86]{berasans}}%
\WriteLine{\string\usepackage[dvipsnames,table,svgnames,xcdraw,showerrors]{xcolor}}%
\WriteLine{\string\usepackage{pstricks}}%
\WriteLine{\string\usepackage{pst-func}}%
\WriteLine{\string\usepackage{rotating}}%
\WriteLine{\string\usepackage{pst-blur}}%
\WriteLine{\string\usepackage{pst-lens}}% Seite 436
\WriteLine{\string\usepackage{pst-slpe}}%
\WriteLine{\string\usepackage{pst-circ}}%
\WriteLine{\string\usepackage{pst-3d}}%%27.07.2012 testweise
\WriteLine{\string\usepackage{pst-3dplot}}%%27.07.2012 testweise
\WriteLine{\string\usepackage{pst-plot}}%%27.07.2012 testweise
\WriteLine{\string\usepackage{pst-coil}}%% 1.7.2014
\WriteLine{\string\usepackage{pst-diffraction}}%%27.07.2012 testweise
\WriteLine{\string\usepackage{pst-vue3d}}%
\WriteLine{\string\usepackage{pst-bar}}%%27.07.2012 testweise
\WriteLine{\string\usepackage{pst-barcode}}%
\WriteLine{\string\usepackage{pst-all}}%
\WriteLine{\string\usepackage{pst-uml}}%
\WriteLine{\string\usepackage{pstricks-add}}%% muß als letztes Paket geladen werden. Erkenntnis vom 27.07.2012, PStricks, 6. Auflage, S.647 letzte Zeile.
\WriteLine{\string\usepackage{pst-fill}}%
\WriteLine{\string\usepackage{pst-light3d}}%
\WriteLine{\string\usepackage{pst-solides3d}}%%27.07.2012 testweise geht nicht
\WriteLine{\string\usepackage{eso-pic}}%
\WriteLine{\string\usepackage{fp}}%
\WriteLine{\string\usepackage{gradientframe}}%
\WriteLine{\string\usepackage[cleanup={log,aux,dvi,ps,pdf}]{auto-pst-pdf}}%
\WriteLine{\string\begin{document}}%
}
%%
\newcommand\Export[1]{%
\stepcounter{psextern}%
\gdef\psexternExt{#1}%
\VerbatimEnvironment%
\begin{VerbatimOut}{\jobname-#1\thepsextern.tex}}
%%
\def\endExport{%
\end{VerbatimOut}
\IfFileExists{\jobname-\psexternExt\thepsextern.tex}
{\typeout{>>>running pdflatex with file ./figures/pdf-export/\jobname-\psexternExt\thepsextern.tex}%
\immediate\write18{pdflatex --interaction=nonstopmode \jobname-\psexternExt\thepsextern}
\immediate\write18{call fcopy \jobname-\psexternExt\thepsextern}
}
{\fbox{Error in Export!}}%
\IfFileExists{./figures/pdf-export/\jobname-\psexternExt\thepsextern.pdf}
{\includegraphics{./figures/pdf-export/\jobname-\psexternExt\thepsextern}}
{\fbox{Error in running \jobname-\psexternExt\thepsextern.tex~ Try again}}%
}
% \usepackage[export]{adjustbox}
\begin{document}
\begin{figure}\centering
\adjustbox{scale=0.25}{
\begin{Export}{fig}
\DeclareFixedFont{\Rm}{T1}{ptm}{m}{n}{3cm}
\begin{pspicture}(-11,-11)(11,11)
\psset{linestyle=none,fillstyle=solid}%
\PstLightThreeDText[fillcolor=Violet, LightThreeDColorPsCommand=2.5 div 0.7 exch 0.8 sethsbcolor]{\Rm 987}\\[1cm]
\PstLightThreeDText[fillcolor=DarkGreen,LightThreeDColorPsCommand=2 div 0.5 exch 0.2 exch sethsbcolor]{\Rm 987}
\end{pspicture}
\end{Export}
}
\end{figure}
\begin{table}[!htb]
\centering
\caption{A caption of a tabular}
\begin{Export}{tab}
\begin{tabular}{ccc}\hline
f & b & b \\\hline
foo & bar & baz \\\hline
\end{tabular}
\end{Export}
\end{table}
\begin{Export}{tab}
\begin{tabular}{l}
\psTilt{60}{%
\begin{tabular}{|p{0.7cm}|p{0.7cm}|p{0.7cm}|p{0.7cm}|p{0.7cm}|}\hline
\psrotateleft{Beispiel Nummer\ } & \psrotateleft{Arbeitsstunden\ }& \psrotateleft{Sekretariat [E/F]\ }& \psrotateleft{Reinigung [E/F]\ }& \psrotateleft{Gewinn\ }
\end{tabular}}\\\hspace*{-2.55em}
\begin{tabular}{|p{0.7cm}|p{0.7cm}|p{0.7cm}|p{0.7cm}|p{0.7cm}|}\hline
1 & 6 & 1E & 1E & 600 \\\hline
2A & 7 & 1F & 1E & 700 \\\hline
2B & 7 & 1E & 1F & 730 \\\hline
3 & 8 & 1F & 1F & \cellcolor{green!25}830 \\\hline
4 & 6 & 1F & 1F & \cellcolor{red!25}530 \\\hline
\end{tabular}
\end{tabular}
\end{Export}
\end{document}
(1) I want to have more possibilities to provide parameters to includegraphics. (scaling, rotatet, pagenumber)
(2) Dependend on one (additional) parameter, I want to use different preambles.
(3) Dependend on one (additional) parameter, I want to use different executions.
(4) Dependend on one (additional) parameter, I want to use a different method to include.
(5) Cropping should be possible.
(6) The last table does not work as expected compiling with pdflatex, but it does latex-divps-ps2pdf
Think about
\begin{Export}[fig-pstricks]{scale=0.5}{angle=90}{page=1}{MOREPARAMS}
\end{Export}
(using pstricks preamble, uses \includegraphics[...]{}...= pstrickscompile
\begin{Export}[fig-tikz]{scale=0.5}{angle=90}{page=1}{MOREPARAMS}
\end{Export}
(using tikz preamble, uses \includegraphics[...]{}...= tikzcompile
\begin{Export}[animate]{scale=0.5}{framerate=12}{filename}{first}{last}{label}{MOREPARAMS}
\end{Export}
(using animate preamble, uses \animategraphics[][...]{}...=
it should be possible to extend the code, because the structure is clear.