[xep-support] PDF "corrupt" after inserting SVG image
grig at renderx.com
Wed Jul 9 01:43:42 PDT 2003
> If I specify the following SVG:
> <svg width="4cm" height="4cm" viewBox="0 0 400 400"
> <rect x="1" y="1" width="40cm" height="40cm"
> This results in an error in Acrobat 6 (not in Xep): it cannot be rendered.
I could not reproduce the problem in Acrobat 5.
> Note that
> <rect x="1" y="1" width="4cm" height="4cm"
> works fine.
There is no difference in the way the two rectangles are encoded, except for
that the first does not fit into the clipping rectangle and gets trimmed. I
why this is causing problems for Acrobat 6.
> How should the SVG width, heigth, viewbox and rectangle dimensions relate
> in order to prevent such problems?
The interplay between these parameters is specified in the SVG
In XEP, 1 inch is mapped to 120 px (= unscaled user units), both for SVG and
for other graphical formats. Note that, according to the SVG spec, absolute
lengths inside an element with a viewBox are pretty meaningful: they are
converted to user units by applying a constant scaling ratio, and since the
user unit itself is modified by scaling, the resulting length will be
from the expected. In your case, the figures are as follows:
- viewBox="0 0 400 400" is mapped to a viewport of 4cm x 4cm using the
preserveAspectRatio="xMidYMid meet". This gives a user unit of 0.1mm
in both directions.
- inside, the rectangle side of 40cm is first converted to user units
(pixels): 40cm = 1890px.
This corresponds to 18.9 cm of real length - well beyond the SVG viewport
As a rule of thumb, I suggest avoiding use of absolute lengths if you set a
produce nothing but confusion, and introduce an extra formatter-dependent
> It looks like a Xep bug anyway.
Well, Acrobat 6 appeared quite recently: it may also contain bugs :-) - or
it may be
that it takes a stricter stance on the PDF spec, and discovers problems we
before. Thank you for the report anyway; it is very useful for us to know
things. We will continue investigation.
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo at renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
More information about the Xep-support