Export to PS/EPS/PDF of 'object' per id ignores viewBox

Steps to reproduce:

  • open Inkscape

  • create two documents from template (use 0.91+devel!):

    • A: page format A4, user unit mm (default template)
    • B: page format A4, user unit px (template 'default px')
  • In each document:

    • add objects of the same size relative to the page
    • group them and note the id of the group ('Shift+Ctrl+O')
    • save a copy as PS (or PDF) with:
      • [ x ] use exported object's size
      • Limit export to the object with ID: enter noted id here

What happened?

A, B: Both generated PostScript files have a correct and identical page format (%%DocumentMedia) and %%BoundingBox, but the size of the object(s) differs: the file generated from case A has wrongly scaled objects.

What should have happened?

The objects are correctly scaled.

Notes:

  1. The reported issue affects PostScript as well as PDF export of an object per id.

  2. The attached SVG files have been created with trunk, i.e. the viewBox is set correctly to define the scalefactor of the SVG user units. The bug is not a regression in trunk (0.91+devel) as such, but more obvious there because the default template uses a drawing scale other than CSS Pixels (“uu = mm”) - any cairo-based exports of an object per id in documents based on the default template in trunk will be affected.

  3. The reported issue also affects files with 'px'-based user units, if the internal resolution of the exporting Inkscape build doesn't match the internal resolution of the version which originally created the file. Even though the files render and measure as expected on-canvas if viewBox and page width/height are defined correctly, the cairo-based export of an object by id ignores the viewBox information and exports objects at the "wrong" scale (note that the page size of the output document is still correct).

  4. The reported issue does not affect cairo-based exports based on page area, or on drawing content (in 0.91 now labeled "use exported object's size", but without specifying an object's id)

Inkscape Version and Operating System:

  • Inkscape Version: 1.1-dev (6b4d57f, 2020-04-01)
  • Operating System: Windows 10
  • Operating System version: 10.0.183

Test files

a4-px-test1.svg a4-mm-test1.svg

Migration info

Reproduced with attached test cases

  • Inkscape 0.91+devel r13857 on OS X 10.7.5 using
  • Inkscape 0.91pre3, Inkscape 0.48.5 on OS X 10.7.5 using

A comment said it also affected PNG export, which I can't reproduce.

A third testfile was attached to the LP report: test5_mm.svg. Exporting its group with the same method returns (replicated in Master)

PostScript file does have an invalid %%BoundingBox ("%%BoundingBox: 0 232 0 233"), the generated PDF file renders empty.

Not sure if this should be separate, the report doesn't give minimal conditions.