0

EDIT: problem was coming from a borked installation of texlive on Opensuse (some packages were not updated, so texlive was a mix of 2017 and 2021).

It seems newer versions of pstricks and/or (pdf)latex break when including a pdf via includegraphics and using pstricks code, unless the includegraphics is hidden inside a \ifpdf ... \fi block. This had always worked until I updated texlive recently.

Here is a minimal example:

\documentclass[10pt]{article}
\usepackage{ifpdf}
\usepackage{pst-all}
\usepackage[on]{auto-pst-pdf}
\begin{document}

%\ifpdf
\includegraphics[height=3.5cm]{some_pdf_file.pdf}
%\fi

\begin{postscript}
\begin{pspicture}(0,0)(18,10)
\pspolygon[fillstyle=solid,fillcolor=lightgray,linewidth=0](0,3)(0,0)(3,0)(3,3)
\end{pspicture}
\end{postscript}
\end{document}

compiling this with pdflatex --shell-escape produces the following error:

Error: /undefined in obj
Operand stack:
   1   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1974   1   3   %oparray_pop   1973   1   3   %oparray_pop   1961   1   3   %oparray_pop   1817   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:736/1123(ro)(G)--   --dict:0/20(G)--   --dict:191/200(L)--   --dict:97/300(L)--   --dict:45/200(L)--
Current allocation mode is local
Current file position is 146540
GPL Ghostscript 9.52: Unrecoverable error, exit code 1
system returned with code 256
PDFCROP 1.40, 2020/06/06 - Copyright (c) 2002-2020 by Heiko Oberdiek, Oberdiek Package Support Group.

!!! Warning: Empty Bounding Box is returned by Ghostscript!
!!!   Page 1: 0 0 0 0
!!! Either there is a problem with the page or with Ghostscript.
!!! Recovery is tried by embedding the page in its original size.

whereas the error disappears after uncommenting the \ifpdf and \fi .

4
  • No problems on windows. I replaced your pdf with example-image.pdf. The ghostscript is a bit newer so I assume you are on another OS. Commented Jan 26, 2022 at 14:34
  • Yes, I'm on linux. Did your output contain the gray square from pstricks? On my side, the compilation actually finishes (with a silent warning), and is missing the gray square...
    – Guillaume
    Commented Jan 26, 2022 at 15:59
  • yes it works for me. You could try lualatex instead. It doesn't need auto-pst-pdf and the postscript environment. Commented Jan 26, 2022 at 17:12
  • I think the problem is that the pst-pdf compilation tries to include the pdf from the includegraphics command, and fails (just like a "normal" latex compilation would fail with no bounding box error).
    – Guillaume
    Commented Jan 26, 2022 at 18:16

1 Answer 1

0

I have no problem with

\documentclass[10pt]{article}
\usepackage{pst-all}
\usepackage[pspdf={-dNOSAFER -dALLOWPSTRANSPARENCY}]{auto-pst-pdf}
\begin{document}

\includegraphics[height=3.5cm]{tiger.pdf}

\begin{pspicture}(0,0)(18,10)
\pspolygon[fillstyle=solid,fillcolor=lightgray,linewidth=0](0,3)(0,0)(3,0)(3,3)
\end{pspicture}
\end{document}

However, running it with lualatex (needs an up-do-date TeX distribution) makes life easier ....

\RequirePackage{pdfmanagement-testphase}% needed for transparency
\DeclareDocumentMetadata{}
\documentclass[10pt]{article}
\usepackage{pst-all,graphicx}
\begin{document}

\includegraphics[height=3.5cm]{tiger.pdf}

\begin{pspicture}(0,0)(3,3)
\pspolygon[fillstyle=solid,fillcolor=lightgray,linewidth=0](0,3)(0,0)(3,0)(3,3)
\end{pspicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .