question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

drawSvgPath doesn't work for me

See original GitHub issue

What were you trying to do?

I attempted to use several SVG icons from https://heroicons.com/ in a PDF document.

Why were you trying to do this?

Hm… I wanted icons? Sorry, funny question.

How did you attempt to do it?

For example, I used this SVG path:

const path = 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z';
page1.drawSvgPath(path, {
  x, y, scale: 2, borderColor: grayscale(0), borderWidth: 2, borderLineCap: 'Round'
});

This is the check-circle icon from https://heroicons.com/ . It should appear like this:

image

What actually happened?

But instead I get this:

image

In this case, at least I can see the main part (check mark) of the icon - but the outer circle isn’t there, with the exception of the broken fragment on the right edge. In the case of some other icons I tried (for instance this exclamation one: M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z), parts of the drawing are simply missing.

What did you expect to happen?

I guess those icons should render correctly, at least I don’t know a reason why they shouldn’t.

How can we reproduce the issue?

I believe it should be possible to reproduce by copying&pasting my code above. The site https://heroicons.com/ has many other icons, and I have only found one (M5 13l4 4L19 7 - a simple check mark) that renders as expected.

Version

1.17.0

What environment are you running pdf-lib in?

Browser

Required Reading

Additional Notes

Towards the end of this report I was beginning to think you didn’t really want to hear about it. More or less the most complicated bug report form I’ve filled in so far - just my 2p.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Hopdingcommented, Nov 6, 2021

Also, thanks for the feedback on the bug report form @oliversturm. This was my first stab at solving the flood of unactionable issues I was receiving that were sucking away my time. Now that I’ve received feedback (from you and others) and had a chance to read several reports submitted with it, I decided to make some changes. The updated version of the form should be less heavyweight and burdensome to fill out. I’d appreciate your thoughts on it! 👍.

1reaction
Hopdingcommented, Nov 6, 2021

@oliversturm thanks for reporting this issue! The SVG embedding code definitely isn’t bullet proof. It’s based on the SVG embedding code used by pdfkit. @Sharcoux’s PR should improve pdf-lib’s SVG support quite substantially and hopefully fix this bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drawing of SVG path does not start from 0 - Stack Overflow
I am drawing some SVG-paths using CSS animations. It all works fine when drawing all the paths at the same time. When adding...
Read more >
Paths - SVG: Scalable Vector Graphics - MDN Web Docs
It can be used to create lines, curves, arcs, and more. Paths create complex shapes by combining multiple straight lines or curved lines....
Read more >
The SVG `path` Syntax: An Illustrated Guide | CSS-Tricks
The path element takes a single attribute to describe what it draws: the d attribute.
Read more >
DrawSVG Not working - GSAP - GreenSock
Hi guys, I'm trying to use the DrawSVG plugin for the first time, and I can't get it to work (ie nothing is...
Read more >
SVG Path Tutorial • Easy to Understand! - YouTube
In this tutorial, I show how with the proper tools anyone can learn to draw their own vector graphics WITHOUT using a drawing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found