Forum Discussion

Norbert86's avatar
Norbert86
Copper Contributor
Jan 23, 2019

Line thickness of SVG changes by exporting docx as PDF

Dear Community,

 

I observed that the line thicknesses of SVG pictures in a docx document get thicker when exported to PDF. I got the impression that Office 365 (Version 1812) changes the line thickness while exporting to a minimal value. Is there any way to keep the original line thickness of the SVG when exporting the docx file to PDF?

 

As a demonstration for the issue, I created via InkScape a file with different line thicknesses (5mm to 0.01 mm) and exported it as 600-dpi PNG and SVG. Both pictures got imported in a docx file and exported as PDF via "save as" (see attached).

 

It can be clearly seen that by exporting to PDF all thin lines of the SVG below a certain threshold became thicker.

 

What can be done to maintain the original line thickness of the SVG while exporting?

 

Thanks for your support!

With best regards,

Norbert

  • Norbert86 – I had the same issue. I seem to have found a workaround that's not too painful.

     

    I've played around with the problem, and to me it seems like Word's PDF export imposes a minimum line thickness of 1px at 96dpi relative to the original image dimensions on imported SVG images. So if the image is set to 100% height and width "relative to original picture size" in Word, lines in that image will have a minimum thickness of 1"/96dpi ≈ 0.01" ≈ 0.26mm in the exported PDF.

     

    Luckily, this minimum thickness is set relative to the original image dimensions – so if the "original picture size" becomes larger, the minimum thickness becomes relatively less.

     

    Obviously, I had made my illustrations (...in Inkscape, too, by the way) the exact size I wanted them to be in my Word document. But after figuring out the above, I scaled them up by a goodly amount (1000% is a nice number and safely pushes my intended minimum line thickness above the magical 0.26mm threshold) and then back down in Word. Now everything looks like I want it to, at the expense of having to explicitly set the image's height and width in Word.

     

    Workaround for the "minimum line thickness" issue:

    1. Scale the original image up (so that your minimum intended line thickness becomes more than 0.01" ≈ 0.26mm).
    2. In Word, scale the imported image back down to its intended dimensions.

     

    Using Inkscape to scale up the original image's dimensions works well, of course, but I've found that scaling up the dimensions of an SVG image is actually even easier and faster to do in a simple text editor than a visual editor.

     

    If you'd like to go that route, do this:

    1. Open the SVG file in a text editor (e.g. Notepad)
    2. At the very top, find the "height", and "width" attributes (right next to "viewBox").
    3. Multiply the "height" and "width" values by (e.g.) 10 and update the attributes accordingly.

    For example, this:

     


    <svg
        xmlns="http://www.w3.org/2000/svg"
        version="1.1"
        viewBox="0 0 150 400"
        height="150"
        width="400">

    ...becomes:

     

    <svg
        xmlns="http://www.w3.org/2000/svg"
        version="1.1"
        viewBox="0 0 150 400"
        height="1500"
        width="4000">

    That's it – no other change needed.

     

    After that change, when you import the SVG file in Word (or Inkscape), it'll appear 10x its original size. In Word, right-click > "Size and Position..." > "Size" > "Scale" > set "Height" and "Width" both to "10%", and you're set.

    • beckychicken's avatar
      beckychicken
      Copper Contributor

      michael-buschbeck-ms: Thanks! This solution worked perfectly for me.

       

      After going to the trouble of converting a bunch of nasty raster images to scalable vector format in a rather large document, I was so disappointed to find upon converting to pdf that some lines had thickened to the point that some of the graphics were no longer legible.

       

      Your solution to scale the original images and the further tip to do so relatively painlessly in a text editor saved the day. Thanks for the detailed explanation and instructions.

      • EFX2023's avatar
        EFX2023
        Copper Contributor

        beckychicken 

         

        Just in case anyone else from the future finds this post and can't be bothered with editing files just to print things out correctly.

         

        A easier work around is to print to PDF not save as a PDF.  You'll miss out on some options like compliancy but if just getting things to print reliably is key this might be easier

        As a side note to get text/objects to print properly remember to convert them to paths in Inkscape or to Shapes in Word (this is more practical for illustrations with some text elements not great for large amounts of copy)

  • Eva Vogel's avatar
    Eva Vogel
    Steel Contributor

    Hello Norbert86! First idea: Try it with adobe illustrator. Did you also tried that converting from SVG to another ps like xps or the PDF creator? I guess, SVG and PDF don`t work together so smoothly...(?)

     

    Greets, Eva.

    • Norbert86's avatar
      Norbert86
      Copper Contributor

      Thanks for your response.

       

      I would appreciate to find a solution with Word as it is the standard software used in our group (I am sure that other software like Ai or Latex could do the job as well. The aim is to combine the advantage of word and SVG)

       

      Exporting the docx via PDFcreator, PDF24, or Adobe PDF results in converting the SVG to a image format (like PNG) and losing the vector properties.

      • Eva Vogel's avatar
        Eva Vogel
        Steel Contributor

        Hello Norbert, I know that Word stuff also ;)  And i think you should get a shareware version with adobe illustrator, only to demonstrate if your task is working with it. I believe it works. Greets, Eva.

Resources