Re: [xep-support] PDF "corrupt" after inserting SVG image

From: Nikolai Grigoriev (
Date: Wed Jul 09 2003 - 01:43:42 PDT

  • Next message: Arjan Loeffen: "RE: [xep-support] PDF "corrupt" after inserting SVG image"


    > 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"
    > </svg>
    > 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
    the fact
    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
    viewBox. They
    produce nothing but confusion, and introduce an extra formatter-dependent
    factor (the
    conversion ratio).

    > 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
    didn't know
    before. Thank you for the report anyway; it is very useful for us to know
    about these
    things. We will continue investigation.

    Best regards,
    Nikolai Grigoriev

    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service

    This archive was generated by hypermail 2.1.5 : Wed Jul 09 2003 - 05:09:57 PDT