-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(Node): pdf/svg output #9185
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
base: master
Are you sure you want to change the base?
Conversation
|
Build Stats
|
ShaMan123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready almost
ShaMan123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add fonts in node
|
@melchiar I think you would be interested in this |
| multiplier = 1, | ||
| enableRetinaScaling = false, | ||
| ...options | ||
| }: TDataUrlOptions = {}): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me it doens't make sense to specify a ctx here.
Can we releage this to a specific node item?
If we need to export something in PDF/SVG using node-canvas, shouldn't we add a method that is specific to that and return something related to that?
We don't have code size issues in node and we are not bound to bundling issues.
Having toCanvasElement that return a canvas element that is good for pdf/svg export buy only if we previously created a specific ctx sounds complicated.
Let's have a toNodePDF and a toNodeSVG ( or whatever it can be called to avoid confusion with current toSVG ) in the node classes.
Take also care that moving away from node-canvas is still a remote option and if there are other libraries that do not require building or that are more canvas compliant, is not granted they will have a pdf or svg export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is why I didn't expose toPDF etc. So we are not bound to node canvas.
Suggest a different way?
6c8b144 to
3eb32df
Compare
This is a really good demo for the website... but that must use codesandbox to run a container... another reason to use codesandbox @asturur |
ShaMan123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebased to head
|
Anyone interested in this great solution bear in mind that it is also possible to achieve it on the client by using canvas API svg renderers. |
|
I love & need this. Can we please add this feature? Can I manually merge these changes in my fork till then? Are there any known issues? |
|
This should be node only and not on the generic methods. Those will work only under node and there should be. |
Motivation
I was in a need for pdf output
Description
Utilizing node canvas' native pdf/svg output by accepting a
ctxas arg fortoCanvasElementfirst merge #9112 for registering fonts
I have come up with a different approach that can be achieved by 2 subclasses: https://codesandbox.io/p/devbox/fabric-node-sandbox-forked-mg9222?workspaceId=d29ca40f-0679-47bb-8fc8-429da561f9e5
Changes
ctxoptional arg/optionGist
In Action
https://codesandbox.io/p/devbox/modern-waterfall-glhq62