Vector image with fixed line width

All we need is an easy explanation of the problem, so here it is.

I would like to create/export a vector image with fixed line widths, independent of the zoom level.
I’ve already found the possibility to use vector-effect="non-scaling-stroke" in an SVG image, which makes the line width independent of my transformations.
But that is not what I want. I need to create an image file that I can send to someone else, while he/she can open it in web/pdf/image browser, zoom in, while keeping the line width fixed.

Example: I have this image:

enter image description here

What I want after enlarging it 10 times in browser/pdf viewer:

enter image description here

What I got instead:

enter image description here

I’m struggling with this for quite long, so I wonder, is it even possible? I understand that with raster images, this is impossible in principle, but isn’t there a way to achieve this with vector images?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

PDF specification has no such capability. PDF is a print preparation/archival/wysiwyg format. Its simply not meant for this usecase.

Like others have said svg files in a browser have this property. But thats not a universal works in all svg rendererers kind of thing. Browsers are especially flexible, so you could even make it thinner when you zoom in if you wanted to.

Method 2

I finally resolved this. Using the information from comments and @joojaa answer, I concluded that PDF is not an option. I focussed on SVG, and I was able to achieve the result using the embedded CSS block with stroke-width property. However, this is not enough to achieve the wanted behavior in the browser.

The key is to set the stroke width in viewport units. Example:

<svg xmlns...">
        path { stroke-width: 0.1vw; }

This solution works for Chrome, Firefox, and Opera. It does not work for IE (it ignores the embedded style), but I guess it is a question for a different community.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply