• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adobe Acrobat Reader errors on SVGs with stroke-miterlimit

New Here ,
Oct 05, 2022 Oct 05, 2022

Copy link to clipboard

Copied

Hi Community,

 

I placed SVGs inside a PDF where some <g> container elements have the attribute `stroke-miterlimit="0"`. It turns out that these attributes are not accepted by Adobe Acrobat Reader and cause not only erronous rendering of the SVG but following elements like tables or other SVGs. I the SVG and produced PDF by using weasyprint (converting example.html to example.pdf).

 

example.html

<!DOCTYPE html>
<body>
  <figure>
    <figure>
      <!-- b64 encoded example.svg -->
      <img
        src="data&colon;image/svg+xml;base64,PHN2ZyBiYXNlUHJvZmlsZT0iZnVsbCIgY2xhc3M9Ik1pc3Npb25zQ2FwYWJpbGl0aWVzQmxhbmsiIGhlaWdodD0iMTAwIiB2ZXJzaW9uPSIxLjAiIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiB3aWR0aD0iMTAwIgogICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZyBzdHJva2UtbWl0ZXJsaW1pdD0iMCI+CiAgICAgICAgPHJlY3Qgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIGZpbGw9ImFxdWEiIC8+CiAgICA8L2c+Cjwvc3ZnPg=="
      />
      <figcaption>This is the SVG caption</figcaption>
    </figure>
    <table>
      <tr>
        <th>Company</th>
        <th>Contact</th>
        <th>Country</th>
      </tr>
      <tr>
        <td>Alfreds Futterkiste</td>
        <td>Maria Anders</td>
        <td>Germany</td>
      </tr>
      <tr>
        <td>Centro comercial Moctezuma</td>
        <td>Francisco Chang</td>
        <td>Mexico</td>
      </tr>
    </table>
  </figure>
</body>

 

The resulting PDF appears to be blank. Nor the SVG, its caption or the table was rendered.

 

Removing these attributes fixes the problem that only occures with Adobe Acrobat Reader (also online version). Opening the PDF with any other PDF viewer (for e.g. in chrome) displays all expected content.

 

Cheers

TOPICS
Crash or freeze , PDF and browsers , View PDF , Windows

Views

872

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2022 Oct 05, 2022

Copy link to clipboard

Copied

I believe that stroke-miterlimit must be greater than or equal to 1 (since the math doesn't work below that). Documented on stroke-miterlimit - SVG: Scalable Vector Graphics | MDN (mozilla.org). Therefore this would be an invalid SVG. Rather than detecting this, the SVG to PDF converter has converted to an invalid PDF. The results are undefined (and blank is entirely possible, since Acrobat Reader suppresses many error messages). Note that the SVG must be converted to PDF graphics, since PDF cannot embed the SVG itself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

Hi,

 

thank you for the quick response. Thanks for pointing out the invalid value of the attribute. Shouldn't be the standard behaviour of the PDF Reader that invalid attributes are just ignored. Then in the worst case only the faulty SVG isn't displayed and not all elements after it. This is the behaviour of different PDF viewers I tested.

 

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

LATEST

"Shouldn't be the standard behaviour of the PDF Reader that invalid attributes are just ignored." The PDF specification makes no such rule. It leaves it undefined, so all behaviours are correct - including ignoring, giving an error, showing a blank, or playing a happy tune... PDF viewers are not validators and the requirement is that input is valid. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines