Line thickness of SVG changes by exporting docx as PDF

Copper Contributor

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

13 Replies

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.

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.

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.

I have been having much difficulties with this problem as well.

 

My Word document has an SVG map with outlined labeling however when exported to PDF the line thicknesses change causing them to looked "blobbed". The line width in Word appears to be ignored.

Microsoft Word view (300%)

Microsoft WordMicrosoft Word

 

Export PDF view (300%)

Exported PDFExported PDF

 

Applications:

  • Windows 10 Pro (Version 1903, OS Build 18362.356)
  • Microsoft Office 365 Business (Version 1908, Build 11929.20300)
  • Adobe Acrobat Reader DC (Version 2019.012.20040)

@Jason Morse 

 

Hello Jason,

 

I could solve the issue in my case the following way:

I create my SVG figures via Ink-Scape (freeware). But, before I want to place a SVG file into word, I use the option "Object to Path" and save it afterwards as SVG. Like that, i.e., the letter "H" is not anylonger stored as a letter, but by three individual lines. When I place this "converted" SVG file into a word file and export it as PDF it keeps its properties.

 

I hope this helps you!

With best regards,

Norbert

@Norbert86,

Thank you for the comment. This SVG was already converted to paths to deal with specialized embedded fonts from ESRI ArcGIS Pro. You will notice that all lines in my previous example above exhibits increased line thicknesses - not just the path'd fonts.

@Jason Morse,

 

I've found a workaround to solve the problem. First convert all object to path (you've done that). After you place the svg in word, right click and try convert to shape. It works perfectly at my end. 

I exported the same docx to pdf on windows 10 and MacOS. Only windows 10 (for me it's 1903) caused the problem.

@Chuanxin LIUfor me your workaround only works to 50%. It indeed solves the problem with the broadened lines, but when making the "conversion to form" in word365 several things happen, like for example the arrows of my inkscape vector graphic also lose their heads.

 

Edit: So for arrows it is also needed to additionally apply "stroke to path" in inkscape on all arrows. Then that also works fine. But still a lot of other problems occur and parts of the vector graphic are missing in the final pdf, although they are visible in the word file after conversion to form.

Thanks for your reply @Chuanxin LIU. Similar to @Zyme86 your workaround has not been successful for me.

 

Converting my SVG to a shape often destroys it or changes many of the shapes to "fat" mode within Word that I cannot change to the expected pen width.

 

The only workaround I have found so far is generating a PDF, converting it to SVG using https://github.com/dawbarton/pdf2svg and then importing to Word. It looks as expected in Word and the resulting exported PDF.

 

Ridiculously complicated for a feature that I would expect to work out of the box. 

@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.

@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.

@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)