Discussion:
xdvipdfmx: wrong annotation rectangle if the pstricks is involved
(too old to reply)
Ulrike Fischer
2018-03-06 14:16:18 UTC
Permalink
If one compile the following document with xelatex then the complete
page is the link area. xdvipdfmx reports:
xdvipdfmx:warning: Annotation out of page boundary.
xdvipdfmx:warning: Current page's MediaBox: [0 0 612 792]
xdvipdfmx:warning: Annotation: [0 0 2375.09 3357.41]
xdvipdfmx:warning: Maybe incorrect paper size specified.

Storing the picture in a box or adding some text didn't change the
behaviour.

The link is create by the specials pdf:bann and pdf:eann which
"tries to determine the boundaries of the annotation automatically"
(from the documentation of dvipdfm) but obviously fails completly
here.

Would it be possible to resolve this on the dvipdfmx/xdvipdfmx side?
(The only other alternative is probably be some href variant in
hyperref which uses pdf:ann instead).



\documentclass{article}
\usepackage{pstricks}
\usepackage{hyperref}

\newcommand{\mypic}{%
\begin{pspicture}(-1,-1)(1,1)
\pscircle(0,0){1}
\end{pspicture}%
}

\begin{document}
\href{https://www.tug.org/texlive/}{\mypic}

\end{document}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Hironobu Yamashita
2018-09-23 06:09:57 UTC
Permalink
Hi Ulrike,

It may be too late but I looked into this, and I guess
the issue is difficult to be perfectly solved by xdvipdfmx.
Post by Ulrike Fischer
If one compile the following document with xelatex then the complete
xdvipdfmx:warning: Annotation out of page boundary.
xdvipdfmx:warning: Current page's MediaBox: [0 0 612 792]
xdvipdfmx:warning: Annotation: [0 0 2375.09 3357.41]
xdvipdfmx:warning: Maybe incorrect paper size specified.
The below is my investigation.

(1) Saving the MWE as test.tex, compile

$ xelatex -no-pdf test
$ xdvipdfmx -vvvv test

shows

%====
Current input buffer is -->pdf:bann<</Type/Annot/Subtype/Link/Border[0
0 1]/H...<--

Current input buffer is -->pst: ***@Dict begin STP newpath /ArrowA {
moveto }...<--
(Image:/var/folders/m8/j64xn09j2_xbqscws7skdbxc0000gn/T/dvipdfmx.tyivt6[/var/folders/m8/j64xn09j2_xbqscws7skdbxc0000gn/T/dvipdfmx.tyivt6][PDF],Page:1)
Current input buffer is -->pdf:eann<--

xdvipdfmx:warning: Annotation out of page boundary.
xdvipdfmx:warning: Current page's MediaBox: [0 0 612 792]
xdvipdfmx:warning: Annotation: [0 0 2375.09 3357.41]
xdvipdfmx:warning: Maybe incorrect paper size specified.
%====
Post by Ulrike Fischer
From the above log, there should be some temporary files involved.
(2) I could find four temporary files (attached), and the last-created one
(the above dvipdfmx.tyivt6) looked like a PDF generated by Ghostscript.
It contained /MediaBox [ 0 0 2384 3370 ]. It seems that these values
were used to calculate annotation rectangle.
(Note: 2375.09 = 2384*72/72.27, 3357.41 = 3370*72/72.27)

(3) Back to dvipdfmx.cfg, distiller parameters (passed to rungs) contain
-sPAPERSIZE=a0
which is the reason why GS has set /MediaBox [ 0 0 2384 3370 ].
I don't know how to create a PDF with tightly-cropped /MediaBox with GS.

(4) BTW, the annotation rectangle is sometimes wrong for EPS image
inclusion too. Note that the distiller parameter -dEPSCrop is effective
for EPS (it wins -sPAPERSIZE=a0), but the annotation rectangle is
always set to the /MediaBox of PDF without scaling.

%====
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\begin{document}
%% wrong rectangle is set as if scale=1
\null\vskip500pt
\href{https://www.tug.org/texlive/}{\includegraphics[width=1cm]{tiger.eps}}
\clearpage
%% rectangle is correct for scale=1
\href{https://www.tug.org/texlive/}{\includegraphics{tiger.eps}}
\end{document}
%====

Hope this helps,
Hironobu Yamashita

Loading...