News for hackers. Stuff that matters.
Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by adrianh on Tuesday December 03, 2024 @03:07PM (#42310703)
At Soundslice, we have a custom sheet-music-rendering graphics library in frontend JavaScript/Canvas.

We also need to generate vector PDFs serverside — so we use a node library that speaks the HTML Canvas API and can generate PDFs. This way the result is exactly the same as the rendered sheet music in the web browser. Nice!

The upshot is: this kind of library allows for code reuse in non-browser contexts.

Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by rafaelmn on Tuesday December 03, 2024 @03:10PM (#42310734)
Is Canvas really suitable for PDFs ? Afaik it's immediate mode bitmap graphics - so PDFs would just be embedded bitmaps ?
Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by adrianh on Tuesday December 03, 2024 @03:13PM (#42310766)
We do indeed generate vector PDFs, not embedded bitmaps.

Our graphics engine works with Canvas API instructions — like "draw a line from point (A,B) to (C,D)." This API is small enough and low-level enough that it can also generate pristine vector output.

That's in fact one of the features of Skia Canvas (vector output in PDF and SVG).

Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by rafaelmn on Tuesday December 03, 2024 @03:24PM (#42310890)
Ah nice didn't know it had a PDF backend - that sounds perfect for this use case.
Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by simonsarris on Tuesday December 03, 2024 @08:33PM (#42313668)
Curious: What other libs are you using for the PDF generation?
Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by DanielHB on Wednesday December 04, 2024 @03:39AM (#42315616)
On a related note, I once used puppeteer and headless chrome in a docker image to generate PDF manuals from our web page documentation using the print to PDF feature of headless chrome.

I am not sure if it would be viable to use for thousands of PDF generation per minute but it worked great. I wasted a lot of time trying to find a good lib for HTML->PDF and they all kinda sucked in different ways. The only downside is that the chrome PDF api doesn't have a way to generate a table of contents with page numbers.

Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by dizhn on Wednesday December 04, 2024 @12:21PM (#42319641)
I have a soundslice account that I use infrequently. It's pretty nice. Thanks for building it and making it available.
Re:Skia Canvas: Browser-Less Implementation of the HTML Canv... by Gabriel_Martin on Thursday December 05, 2024 @02:16AM (#42325785)
When you mentioned Soundslice I recognized your name :) Your recording of Django's Tiger is what got me into Jazz. Small world!