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

Library produces different results in browser vs nodejs #1589

Open
2 tasks done
laszlo1337 opened this issue Jan 17, 2024 · 0 comments
Open
2 tasks done

Library produces different results in browser vs nodejs #1589

laszlo1337 opened this issue Jan 17, 2024 · 0 comments

Comments

@laszlo1337
Copy link

laszlo1337 commented Jan 17, 2024

What were you trying to do?

Generate PDF with svg path

How did you attempt to do it?

Implemented code in JS fiddle, where it works perfectly https://jsfiddle.net/5avk4jwd/

What actually happened?

The same code ported to nodejs produces entirely different results - the SVG is drawn in a wrong position and drawing rectangle actually results in rectangle being over the SVG path, even though it's drawn earlier like in above example

correct result from the browser: https://github.com/foliojs/pdfkit/files/13943064/4282dfc2-f3f1-4399-9ec4-191e59185540.pdf
wrong result from nodejs: https://github.com/foliojs/pdfkit/files/13943074/2SFtR3p2.pdf

correct browser result if bg enabled: https://github.com/foliojs/pdfkit/files/13943189/8b7edae8-0a0c-412d-8fa9-4412d5963b9d.pdf
invalid nodejs result: https://github.com/foliojs/pdfkit/files/13943180/5Hl7kt4n.pdf

What did you expect to happen?

Produce the same output as in the browser

How can we reproduce the issue?

https://jsfiddle.net/5avk4jwd/ - the code is here.
paste the same code in NodeJS environment

Version

1.17.1

What environment are you running pdf-lib in?

Browser, Node

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

This is the exact same issue that's happening in pdfkit library, where I aleady created an issue foliojs/pdfkit#1490
the produced pdf results are exact same - wrong svg placement and wrong draw order.

important: edits

EDIT: I solved the wrong placement issue - turns out that was the fault of invalid path. But ordering issue still prevails

EDIT2: Perhaps the layering issue it not really what it seems. Now to me it looks like instead of my SVG path the function draws and strokes the previous rectangle shape. I tried looking for any reset, path end etc related functions in pdflib api but nothing works

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

1 participant