[dvipdfmx] XObject form bounding box problem
Petr Krajník
petrkrajnik at outlook.cz
Sat Jul 6 13:17:44 CEST 2019
> I assume you are talking about XObject created via pdf:bxobj/pdf:exobj
> special below.
Yes. If I would using direct code as direct literal that discussion
wouldn't exist as setting up BBox and Matrix would be in my hands.
>> 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.
>
> You mean the lower left corner of the bounding box is set to the current
> position where pdf:bxobj is inserted and XObject's Matrix dicrionay entry
> is adjusted accordingly?
>
> I find no strangeness here, dvipdfmx is just using the easiest way to
> capture the contents of a page: It adjusts BBox and Matrix of XObect
> instead of converting coordinates values of each drawn objects.
>
If I have a isolated object why should I calculate the position where
the object was first issued by pdf:bxobj and pdf:exobj into the bbox and
matrix? For me that violates the idea of isolation of xobjects. And
that's exactly is the root of the problem that I describe...
So for example:
Let us assume we have \hoffset=100pt and \voffset=0pt. And first thing
in the code we introduce the xobject.
\hoffset=100pt \voffset=0pt
\special{pdf:bxobj @test width 100pt height 10pt depth 0pt}
CODE of XObject
\special{pdf:exobj}
The result is this:
/BBox[99.626 0 199.253 9.963]/Matrix[1 0 0 1 -99.626 0]
Then the left corner [0,0] is shifted by -99.626bp (hoffset, 100pt) by
the xobject Matrix. As the result we are -100pt away from the point
where the xobject was called and where the [0,0] point should be. Every
x coordinate need to be advanced by 100pt to hit that bounding box!
>> 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.
>
> The cm operation is always required for pdf:content. It is intended for
> drawing an isolated graphics object somewhere on the page.
> The current point should be always selected as the origin inside
> pdf:content special, not somewehre else.
> Do you mean that the lower left corner of the page or XObject shold
> be emplyoed for the origin?
No. There is everything alright with pdf:content. I only think that is
is unnecessary inside xobject, as in isolated object, the coordinates
should be already set when entering stream of the xobject. No additional
CM for shift to the right coordinates shouldn't be needed. But due to
the unpractical calculation of BBox and Matrix there is need to insert
additional CM to the content stream to get to the right coordinates
inside the bounding box. That is reason why pdf:content works as it
insert such matrix into the content stream of the xobject.
>> 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?
>
> I am not sure what is your intent here. Do you mean BBox should be
> always something like [0 0 urx ury]?
>
Yes. As we use it pdf:bxobj width ?pt height ?pt depth ?pt it should be
always [0 -depth width height]. There is no need to transform
coordinates in any way. As when using pdf:usexobj special that inserts
correct CM matrix for setting up position properly before calling
xobject form.
If we are using bbox with pdf:bxobj it should be the same.
pdf:bxobj bbox 0 -5 10 10 should be BBox [0 -5 10 10]. Maybe that should
be converted from tex points to big point. But nothing else.
> I understand your point regarding pdf:code you mentioned in another
> email but using pdf:content instead is the right way I think.
OK. Thank you. That was the solution that I finally used.
Thanks And sorry for the late reply.
Best regards
Petr Krajník
More information about the dvipdfmx
mailing list