PDF export size

Asked by Alex Felippe Chiozo

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

Language:
English Edit question
Status:
Solved
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Solved by:
Mc
Solved:
Last query:
Last reply:
Revision history for this message
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 )

Revision history for this message
Alex Felippe Chiozo (uragawa) said :
#2

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

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="44"
   height="44"
   viewBox="0 0 11.641667 11.641667"
   version="1.1"
   id="svg4672"
   inkscape:version="0.92.0 r"
   sodipodi:docname="clock.svg">
  <defs
     id="defs4666" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1"
     inkscape:cx="-22.761906"
     inkscape:cy="-2.79877"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     units="px"
     fit-margin-top="0"
     fit-margin-left="0"
     fit-margin-right="0"
     fit-margin-bottom="0"
     inkscape:window-width="1396"
     inkscape:window-height="855"
     inkscape:window-x="0"
     inkscape:window-y="23"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata4669">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-7.0807542,-9.4511503)">
    <g
       transform="matrix(0.16960488,0,0,-0.16960488,-5.7966465,19.260212)"
       id="g4616"
       style="fill:#000000;fill-opacity:1">
      <path
         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"
         style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1"
         id="path4557"
         inkscape:connector-curvature="0" />
      <path
         d="m 117,19.6805 h -9 v 15 h 3 v -12 h 6 v -3"
         style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1"
         id="path4583"
         inkscape:connector-curvature="0" />
    </g>
  </g>
</svg>

Revision history for this message
Best Mc (mc...) said :
#3

== Explanation ==

The important part in your file is

   width="44"
   height="44"

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]

Revision history for this message
Alex Felippe Chiozo (uragawa) said :
#4

Thanks Mc, that solved my question.