PDF export size

Asked by Alex Felippe Chiozo on 2017-07-14

I use Inkscape (0.92.0_6+quartz from MacPorts on macOS 10.12.5) to edit vector drawings and for a long time I'd export them to PNG at the proper sizes for use in Xcode. When I found out that Xcode supports using PDF files that it renders at the correct size at build time, I started using that feature whenever possible. My display and page size units are all pixels. I find however that when Xcode reads my exported PDFs it consistently reports 75% of the size (in pixels) used in Inkscape. Changing the dpi in the PDF export dialog doesn't seem to affect anything.

It seems that the issue, whether it's a bug or a setting I'm missing, is on Inkscape's side, since Illustrator reports the same size as Xcode. Also, saving the Inkscape drawing as SVG, then opening it in Illustrator, exporting as PDF and opening that in Inkscape results in Inkscape's reporting 133.33% of the size.

[Edited after first reply to add:] I tried exporting the PDF from LibreOffice Draw instead and in regards to document size the behaviour is similar to Illustrator: correct size reported by Xcode and 133.33% by Inkscape.

Is there any way of working around this short of actually resizing my drawings?

Question information

English Edit question
Inkscape Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Mc (mc...) said : #1

can you attach the svg ? Just to make sure that the document width and height are set in px

Also note that almost all adobe product have a bug making them force a 1in=72px rato, while inkscape follows the css spec (1in=96px) ( https://www.w3.org/TR/css3-values/#absolute-lengths )

Alex Felippe Chiozo (uragawa) said : #2

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

   viewBox="0 0 11.641667 11.641667"
   inkscape:version="0.92.0 r"
     id="defs4666" />
     inkscape:window-maximized="0" />
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
     inkscape:label="Layer 1"
         d="m 110.246,40.0148 c -9.099,0 -16.5003,-7.4015 -16.5003,-16.5 0,-9.098 7.4013,-16.49996 16.5003,-16.49996 9.098,0 16.5,7.40196 16.5,16.49996 0,9.0985 -7.402,16.5 -16.5,16.5 z m 0,-35.99996 c -10.7526,0 -19.5003,8.74766 -19.5003,19.49996 0,10.7528 8.7477,19.5 19.5003,19.5 10.752,0 19.5,-8.7472 19.5,-19.5 0,-10.7523 -8.748,-19.49996 -19.5,-19.49996"
         inkscape:connector-curvature="0" />
         d="m 117,19.6805 h -9 v 15 h 3 v -12 h 6 v -3"
         inkscape:connector-curvature="0" />

Best Mc (mc...) said : #3

== Explanation ==

The important part in your file is


so your file is supposed to be 44x44px.

When I export to pdf (using inkscape 0.92.1) I get this size (just open the pdf in a text editor) :
<< /Type /Page
   /Parent 1 0 R
   /MediaBox [ 0 0 33 33 ]
   /Contents 3 0 R
   /Group <<
      /Type /Group
      /S /Transparency
      /I true
      /CS /DeviceRGB
   /Resources 2 0 R
According to http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf (p79) the default user unit of pdf is "1/72 of an inch" (="pt").

So the pdf file is 33x33pt, which is, for pdf purposes, equal to 0.4583(3) inches. Now the problem is that pdf only really thinks in this unit, meaning for css-related purpose, we're fine (this is still equal to 44px), but for apps that hardcode a 72dpi value, you'll end up with 33px.

When you open the *pdf* produced by inkscape with libreoffice, the size reported is correct (the page is reported as 0.46 inches); and when you open the svg, it transforms the pixel size of the file into inches with a 72 dpi factor (for instance, http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1graphic_1_1XGraphicRasterizer.html uses 72). It's probably the same with XCode, and definitely that with adobe products (their internal unit is the inch and only display "px" as a convenience)

So it really comes down to the problem of what a pixel-inch conversion ratio is : you seem to expect Inkscape to follow the "non-standard" value of 72dpi (that ultimately comes from adobe postscript), while Inkscape supports the w3c-standardized ratio of 96dpi.

(The problem is that pdf only supports inches, so you do a px->inch->px double conversion while you should be able to import px-measured svg into your px applications)

== Solution ==

In Inkscape, go to document properties and
-> set your display units to use "pt" instead of "px" because pt are really what your applications think are pixels if you go through pdf as an intermediary format. Your document size should be 44x44ptĀ²
-> If you don't want to manually scale, set 0.75 user unit per millimeter (since your document was apparenly created by a millimeter-sized template) [for that, temporarily set display units to mm, see that scaleX is 1, change it to .75; reert display units to pt]

Alex Felippe Chiozo (uragawa) said : #4

Thanks Mc, that solved my question.