1

I have a pdf file which contains a figure in it. I can insert it by LuaLaTeX or pdfLaTeX, but can't be inserted by XeLaTeX. What is the reason?

\documentclass{article}
\usepackage{graphicx}

\begin{document} \begin{figure} \includegraphics[]{1.pdf} \end{figure}

\end{document}

The error in XeLaTeX is

xdvipdfmx:fatal: Image inclusion failed for "./1.pdf" (page=0).

Just download the file and you can duplicate this error.

The download address

Y. zeng
  • 1,885
  • your links asks for a password, I won't do that. – Ulrike Fischer Oct 11 '23 at 15:21
  • @UlrikeFischer Thanks for your kind reply. I updated it now. – Y. zeng Oct 11 '23 at 15:26
  • @UlrikeFischer it doesn't now – David Carlisle Oct 11 '23 at 15:26
  • @DavidCarlisle I can download it in the incognito window of Chrome. It is weird. – Y. zeng Oct 11 '23 at 15:28
  • @Y.zeng the download worked for me, I assumed you had changed the settings after Ulrike said it required a password, did you not? There is something weird about that pdf:-) – David Carlisle Oct 11 '23 at 15:36
  • 1
    my pdfsyntax checker reports errors in this file and xdvipdfmx complains: xdvipdfmx:warning: Cannot parse cross-reference stream. xdvipdfmx:warning: Error while parsing PDF file. – Ulrike Fischer Oct 11 '23 at 15:38
  • @DavidCarlisle The first link is from personal Onedrive. I even don't know how to set password. And the second is from Business Onedrive. – Y. zeng Oct 11 '23 at 15:39
  • 2
    After seeing @DavidCarlisle response below: Do you have Linux or other system with command line (BASH) ? If so, install program qpdf. It can inspect a PDF file and report file errors. My guess is that 1,pdf has a non-fatal internal syntax error, ignored some software but not by other software. – rallg Oct 11 '23 at 15:48

1 Answers1

1

There seem to be syntax errors in the original pdf that prevent xdvipdmx from reading the file, but if you do

pdf2ps 1.pdf
mv 1.ps 1b.ps
ps2pdf 1b.ps

so that ghostscript re-writes the pdf, and change the tex to include 1b.pdf instead, it runs without error in xelatex and produces

enter image description here

David Carlisle
  • 757,742
  • Have you tried the xelatex engine? – Y. zeng Oct 11 '23 at 15:34
  • @Y.zeng yes the above output is xelatex – David Carlisle Oct 11 '23 at 15:36
  • @Y.zeng I got the error that you showed with the original 1.pdf – David Carlisle Oct 11 '23 at 15:38
  • 2
    What is the reason? Solving problems is good, finding problems is good. I want to know why an error is reported. – Y. zeng Oct 11 '23 at 15:40
  • @Y.zeng sorry a pdf file is a binary file, if its internal structure is incorrect then you can't just look at it and see what is wrong. ghostscript is quite good at correcting minor errors on input, and if it can read it, it almost always writes corrrect pdf. So I can't tell you what is wrong (Ulrike found a tool to give some error message, in the comments under the question). All I can tell you is that ghostscript silently corrects it on reading the file. – David Carlisle Oct 11 '23 at 15:56
  • xetex is less forgiving with invalid pdf than pdftex and luatex are. This kind of issue pops up every once in a while, e.g. https://tex.stackexchange.com/q/196644/82917, https://tex.stackexchange.com/q/374488/82917 – campa Oct 11 '23 at 15:57
  • @DavidCarlisle Okay. Thanks a lot. At least I knew why I can't know the error deeply. – Y. zeng Oct 11 '23 at 15:58
  • @campa The pdf format is perfect as it can't be find the error in it and even it has an error, the Adobe wouldn't show any information about it. – Y. zeng Oct 11 '23 at 15:59