2

This seems to be a bug in Apple's pdfKit. However, as this problem only occurs if xelatex is used (works fine with pdflatex), I am hoping that someone here can help with some sort of workaround that allows this to work on a Mac with Apple pdfKit.

As, I have encountered numerous problems with Apple's pdfKit ever since High Sierra, I can't really want to wait around for them to fix it.

Requirements:

I need to use xelatex as I am using an iOS font.

I need a blurred version of an image that I can include in a pdf document. For the MWE presented below, I use a pdf from the mwe package and create (details below) two .png files using convert from ImageMagick . One is the normal.png image and the other is the blur.png.

Results:

After creating a normal and a blurred image:

    \includegraphics{normal.png}
    \includegraphics{blur.png}
    \includegraphics{normal.png}

yields the following depending on the engine used:

  1. Using pdflatex yields the following correct view (in TeXShop, Preview and Acrobat), where all three images are displayed: normal, blur, normal.

enter image description here

  1. Using xelatex yields the following view (in TeXShop and Preview), where the blurred image is not displayed:

enter image description here

Note:

  • The view in Acrobat is fine no matter which option is used! That is, Acrobat ALWAYS display three images.
  • Dropbox app on iOS and on Safari browser is able to display it fine as well. I would think that Safari would be using the same pdfKit as Preview, but there appears to be a difference.

System:

Listfiles pdflatex:

 *File List*
 article.cls    2019/12/20 v1.4l Standard LaTeX document class
  size10.clo    2019/12/20 v1.4l Standard LaTeX file (size option)
graphicx.sty    2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  pdftex.def    2018/01/08 v1.0l Graphics/color driver for pdftex
   iftex.sty    2020/03/06 v1.0d TeX engine tests
l3backend-pdfmode.def    2020-08-07 L3 backend support: PDF mode
supp-pdf.mkii
epstopdf-base.sty    2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
  normal.png    Graphic file (type png)
    blur.png    Graphic file (type png)
  normal.png    Graphic file (type png)
 ***********

Listfiles xelatex:

 *File List*
 article.cls    2019/12/20 v1.4l Standard LaTeX document class
  size10.clo    2019/12/20 v1.4l Standard LaTeX file (size option)
graphicx.sty    2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
   xetex.def    2017/06/24 v5.0h Graphics/color driver for xetex
   iftex.sty    2020/03/06 v1.0d TeX engine tests
l3backend-xdvipdfmx.def    2020-08-07 L3 backend support: xdvipdfmx
  ts1cmr.fd    2019/12/16 v2.5j Standard LaTeX font definitions
  normal.png    Graphic file (type bmp)
    blur.png    Graphic file (type bmp)
  normal.png    Graphic file (type bmp)
 ***********

Code:

Before running the MWE below, you will need to create the two necessary images:

 cp /usr/local/texlive/2020/texmf-dist/tex/latex/mwe/example-grid-100x100bp.pdf normal.pdf
 convert                            normal.pdf normal.png
 convert -filter Gaussian -blur 0x2 normal.pdf blur.png 

This problem is not specfic to an image, so you can use your favorite image if desired.


\documentclass{article}
\usepackage{graphicx}

\usepackage{iftex}
\ifXeTeX
    \def\EngineUsed{xelatex}%
\else
    \def\EngineUsed{pdflatex}%
\fi

%\listfiles
\begin{document}
    Output using \EngineUsed.
    \par
    %% ----------------------------------
    \fbox{%
        \includegraphics{normal.png}
        \includegraphics{blur.png}
        \includegraphics{normal.png}%
    }%
\end{document}
8
  • 1
    it would easier to test if you would put the images somewhere for download (and it would exclude the possibility that it depends on the imagemagic version). (Side remark: your versions doesn't look as if you have updated lately). Commented Oct 15, 2020 at 20:54
  • I don't have a Mac to test it, but maybe Preview prints warnings/errors/diagnostics of any kind to stderr or stdout that you can see when you start Preview from the terminal on this file?
    – Marijn
    Commented Oct 15, 2020 at 21:04
  • @UlrikeFischer: Included links to images as generated via convert and version info of convert as well. Haven't updated my TeXLive 2020 distribution as I am trying to release a product. But, if it is determined that will resolve the issue, I'll do it. Commented Oct 15, 2020 at 21:11
  • 1
    It seems definitely a problem with the PDFKit.
    – egreg
    Commented Oct 15, 2020 at 22:54
  • 1
    Found a workaround: Using a .jpg file does not seem to have the same problem. So, no longer urgent for me to find an immedaite fix. Commented Oct 17, 2020 at 6:14

1 Answer 1

2

There must be some problems (either in PDFKit or dvipdfmx) in supporting FlateDecode predictor filter for 16bit gray color images, which is used for SoftMask of blurred image.

As a workaround for this problem, using the following dvipdfmx option should help

-C 0x20

Alternatively, you can insert the following \special instruction (in the first page)

\special{dvipdfmx:config C 0x20}

in your TeX file to control dvipdfmx behavior.

1
  • Hey! It works! :-D
    – egreg
    Commented Oct 18, 2020 at 9:14

You must log in to answer this question.

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