printing to pdf a score

338 views
Skip to first unread message

giovanni cortese

unread,
Feb 2, 2016, 4:55:00 AM2/2/16
to vexflow, Mirko Boniatti
Hi all - 

I am trying to (pretty..)printing a score (may have of course more than one page)  to pdf for printing/ sharing.

Can somebody share their experience ?
Would starting from canvas or svg a better path ?

We have done some initial attempt (canvas to png to pdf) - first impression (without having tried to tune honestly ..) is that a) seems slow and heavy b) rendering of notes seems not accurate/ low quality

Thanks a lot in advance!
giovanni



Mohit Muthanna Cheppudira

unread,
Feb 2, 2016, 9:52:04 AM2/2/16
to vexflow, Mirko Boniatti
If you're simply going to convert to PDF, then SVG is far better, since it's entirely vector based. Vexflow now works from inside NodeJS, incase you want to generate the PDFs directly.

--
--
You received this message because you are subscribed to the Google
Groups "vexflow" group.
To post to this group, send email to vex...@googlegroups.com
To unsubscribe from this group, send email to
vexflow+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/vexflow?hl=en

---
You received this message because you are subscribed to the Google Groups "vexflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vexflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]

Gregory Ristow

unread,
Feb 2, 2016, 4:39:29 PM2/2/16
to vexflow, mirko.b...@gmail.com, mo...@muthanna.com
To follow up on Mohit's answer, it is relatively easy to do in nodejs, using librsvg. The only trick is getting the SVG as an xml string, you'll need to require an xml serializer. I use xmldom:

  var xmldom = require('xmldom');
  var s = new xmldom.XMLSerializer();
 
var svgString = s.serializeToString(ctx.svg); //ctx is the VexFlow SVG rendering context

If the SVG is on the client side, you can just do s = new XMLSerializer(), and then post the svgString to a server with librsvg.

Taehoon Moon

unread,
Feb 3, 2016, 3:24:30 AM2/3/16
to vexflow, mirko.b...@gmail.com, mo...@muthanna.com
Hello,
what I know for current vexflow node.js support is limited only for scores without text. Because of svg text getting bounding box issue(getBBox), it's not fully possible to use text in node.js, isn't it?

To use full feature of vexflow serverside, you may need to use SlimerJS(http://slimerjs.org/) or PhantomJS(http://phantomjs.org/).


2016년 2월 3일 수요일 오전 6시 39분 29초 UTC+9, Gregory Ristow 님의 말:

giovanni cortese

unread,
Feb 3, 2016, 4:50:46 AM2/3/16
to vexflow, mirko.b...@gmail.com, mo...@muthanna.com
Hello, thanks to all for the quick answer. We'll give SVG a try - however we will be running Vexflow on the client side (we aim to make an hybrid app for mobile ..). Maybe some of the libraries for svg can be 'browserified' - or we can change our mind and offload the pdf generation to a nodejs server.

Any idea/ suggestion regarding laying out the page for printing - I guess all the math for splitting a score in pages, deciding size of the stave/ zoom etc is responisibility of the application ? Or there is some support / example in vexflow ?

kindly,
giovanni

Tom B.

unread,
Apr 28, 2021, 7:52:53 PM4/28/21
to vexflow
HI I now this is very old but did anyone ever get rendering to Pdf working?
Best 
Tommy BAnana

Simon Schmid

unread,
Apr 29, 2021, 8:18:40 AM4/29/21
to vex...@googlegroups.com
You can get the context.svg and print it to pdf with a framework, e.g. with jsPDF.

Example code, a bit different because it's our MusicXML framework in Typescript, but should be adaptable:
https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/blob/69ff4a62f4a2c487cfb91aed46eec5b617b5749e/demo/index.js#L828

Tom Bancroft

unread,
Apr 29, 2021, 9:08:33 AM4/29/21
to vex...@googlegroups.com
Thanks so much!
Checking it out!

Best 
Tom B.

--
--
You received this message because you are subscribed to the Google
Groups "vexflow" group.
To post to this group, send email to vex...@googlegroups.com
To unsubscribe from this group, send email to
vexflow+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/vexflow?hl=en

---
You received this message because you are subscribed to the Google Groups "vexflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vexflow+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages