Welcome Guest Search | Active Topics | Sign In | Register

SVG images rendered blurry Options
Phil
Posted: Friday, September 19, 2025 8:22:29 AM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2017
Posts: 79
Hello, we are using EO-PDF v25.2.1 (I've also tried using v25.2.36) consumed by a .Net-Core 8 web-API (Angular UI). The images in our UI when viewed within the browser are sharp however when generated within the PDF they appear blurry - I have sent a test project

Are we able to make these images sharper within the PDF ?

Kind regards
Phil
eo_support
Posted: Friday, September 19, 2025 6:29:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,421
Hi,

The test project you sent to us doesn't seem to be working. It appears that the HTML file relies on resources from "localhost:5001" which is not avaliable from the test app. Do you have a self contained or hosted test HTML file we can use?

Thanks!
Phil
Posted: Monday, September 22, 2025 1:26:52 AM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2017
Posts: 79
Hi - many thanks for the quick reply - my apologies for that - I've sent through another test project with the correction
eo_support
Posted: Monday, September 22, 2025 12:49:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,421
Hi,

Thanks for the new test project. We were able to find out the root cause to be SVG fill using a pattern. For example the following SVG would trigger this problem:

Code: HTML/ASPX
<svg 
     xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:NS1="dsrs" 
     NS1:xmlns:xlink="http://www.w3.org/1999/xlink" 
     width="20" height="20" viewBox="0 0 20 20">
    <defs>
        <pattern x="0" width="10" height="10"
                 patternUnits="userSpaceOnUse" patternContentUnits="userSpaceOnUse"
                 id="test-pattern" y="5" patternTransform="scale(1.5)">
            <rect x="1" y="4" width="4" height="4" 
                  transform="rotate(45 1 2.5)" fill="#aed3f0" 
                  style="stroke:#231f20; stroke-width: 1"></rect>
        </pattern>
    </defs>
    <g>
        <rect width="20" height="20" 
              style="fill: url(&quot;#test-pattern&quot;);">
        </rect>
    </g>
</svg>


Note inside this SVG file the rect is filled with pattern "test-pattern". Whenever a pattern is used in SVG, the SVG render would generate a bitmap for that pattern and then apply that bitmap wherever the pattern is to be applied. This process loses the benefits of the vector nature of the SVG image. The same process occurs when rendering to the screen as well --- however if you zoom in on the screen, the rendering process is executed again thus a bigger (and nicer looking) bitmap is rendered. However the same does not occur with PDF file. The original small image is rendered when the PDF file is generated and if you zoom in on the PDF file, it simply enlarges the original small image on screen.

In order to avoid this, you must avoid using patterns in your SVG file. One way to do this is to put each icon in a separate SVG file (for example, one for checkerboard, one for diamond) and then use multiple images element to repeat the icon instead of relying on SVG pattern to repeat it inside a single SVG.

Sorry that there isn't a simpler workaround. Please feel free to let us know if you still have any questions.

Thanks!
Phil
Posted: Tuesday, September 23, 2025 3:39:11 AM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2017
Posts: 79
Really appreciate the clarification and providing a solution - will have a look at replacing the patterns with separate SVG's
eo_support
Posted: Wednesday, September 24, 2025 8:45:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,421
You are very welcome. :)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.