[dvipdfmx] XObject form bounding box problem

Alexander Grahn A.Grahn at web.de
Thu Jun 20 13:35:03 CEST 2019


On Wed, Jun 19, 2019 at 12:31:30PM +0000, Petr Krajník wrote:
>Hi, while working an optimizing PDF output from dvipdfmx I found some 
>strange thing when working on XObject forms. It seems, that the \hoffset 
>and \voffset are added to the bounding box and xobject matrix. So the 
>code would shifted values by \hoffset resp. \voffset.
>
>I think that in many of use cases this problem is masked as user use 
>pdf:literal or pdf:content specials that inserts the correct cm matrix 
>that correct the coordinates. But these additional matrixes are not 
>needed without the problem above.
>
>Is there a reason for adding \hoffset and \voffset to the bounding box? 
>I think its a bug as isolated xobject should not be bounded to these 
>values. Or I missed something?

The /BBox and /Matrix entries of the XObject are correct. The BBox coordinates
correspond to the location where the `bxobj' special was issued.

The BBox in local coordinates of the XObject come into play when the XObject
is referenced (pdf:uxobj special) elsewhere on the page. BBox local coordinates
are obtained by

[ llx* lly* 1 ] = [ llx  lly  1 ] . [ Matrix ]
[ urx* ury* 1 ] = [ urx  ury  1 ] . [ Matrix ]

where the elements of `Matrix' are taken from the
/Matrix [ <a> <b> <c> <d> <tx> <ty> ] entry in the XObject according to 

<a>  <b>  0
<c>  <d>  0
<tx> <ty> 1

In terms of local coordinates, the coordinate [0 0] corresponds to the
reference point of the XObject to be inserted.

XObjects are supposed to be self-contained encapsulated entities that store
typeset content for later replay. Thus, it is quite natural to also store the
text colour that was effective upon creation of the XObject. Thus,
colour injection is not possible when referencing an XObject. This is
the same behaviour as with LaTeX \savebox+\usebox.

An example:

  \documentclass[dvipdfmx]{article}
  \usepackage[a4paper]{geometry}
  \usepackage{color}
  
  \parindent=0pt
  \makeatletter
  
  \begin{document}
  \leavevmode%
  \savebox{0}{\fbox{Hello World!}}%
  %%%%%%%%%%%%%%%%%%%
  % XObject creation
  %%%%%%%%%%%%%%%%%%%
  \special{pdf:bxobj @myform
    width \strip at pt\wd0 pt
    height \strip at pt\ht0 pt
    depth \strip at pt\dp0 pt}%
  \makebox[0pt][l]{\usebox{0}}%
  \special{pdf:exobj}%
  %%%%%%%%%%%%%%%%%%%%
  % XObject insertion
  %%%%%%%%%%%%%%%%%%%%
  \color{blue}% no colour injection with pdf:uxobj and \usebox
  \fbox{Hello World!}\quad
  \makebox[\wd0][l]{\special{pdf:uxobj @myform}}\quad%
  \makebox[\wd0][l]{\special{pdf:uxobj @myform}}\quad%
  \makebox[\wd0][l]{\special{pdf:uxobj @myform}}\quad%
  \usebox{0}%
  \end{document}

Alexander


More information about the dvipdfmx mailing list