Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having problem with SVG path #1578

Open
2 tasks done
jaysridhar opened this issue Dec 25, 2023 · 1 comment
Open
2 tasks done

Having problem with SVG path #1578

jaysridhar opened this issue Dec 25, 2023 · 1 comment

Comments

@jaysridhar
Copy link

What were you trying to do?

It appears that the positive direction of y-axis in pdf-lib is down rather than up as per pdf spec. Is this correct? Or am I doing something wrong.

How did you attempt to do it?

In the snippet below, I am drawing a horizontal line at the bottom of the pdf at -2 units. Next I draw a vertical line at x=100. But to get the vertical line upwards, I have to specify a y of -100. It does not work if I specify y=100. Is this supposed to be how it works?

let svgStr = 'M 0,-2 L 1000,-2 M 100,-2 l 0,-100'
      page.drawSvgPath(svgStr, {
        x: 0,
        y: 0,
        color: rgb(1.0, 0, 0),
        borderWidth: 2
      })

What actually happened?

A vertical line from bottom to top should be y=100. Instead it works only if I specify y=-100.

What did you expect to happen?

I expected the line to be drawn from bottom to up when y = 100

How can we reproduce the issue?

https://jsfiddle.net/crispduty/spmvwdtk/17/

Version

1.17

What environment are you running pdf-lib in?

Browser

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

@ZiarayZ
Copy link

ZiarayZ commented Feb 6, 2024

If this was "fixed" svg paths would be drawn upside down...
This is just a difference between svgs and pdf in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants