-
Notifications
You must be signed in to change notification settings - Fork 11
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
Generate sheetbook PDFs automatically #64
Comments
I just wanted to mention that I started working on this: https://tuxor1337.github.io/ror-sheets-from-player/ (you need to enable JavaScript in your browser to see the result). Look at "Funk", "Karla Shnikov", and "Walc(z)" as well as the "General Breaks" to see some tunes for which I already started to refine the layout. The source code is here: https://github.com/tuxor1337/ror-sheets-from-player I didn't exactly follow all of your suggestions. So far, I only implemented the first steps that seemed logical to me. I copied the tunes in json format from I'm mentioning this because I will not have time to continue working on this before October. In the meantime, please feel free to look into what I did and play around with the code if you are interested. I will inform you in this issue, once I continue working on this. |
@tuxor1337 This already looks really amazing! How would you suggest to proceed with this? Do you want to continue the work on this? Or would you mind if I converted your code to Vue.js and integrated it into the player as a first “tune sheet preview” feature that can be refined more and more? |
Thanks for your feedback! A "tune sheet preview" feature would be very nice. However, I acknowledge that my code is currently in a rather messy state and very long. If you feel like it's really hard to integrate this into the RoR player, feel free to wait a bit longer. I will probably clean up at some point. By the way, I continued working on this in the last three months, but forgot to push my changes - until now. Now you find the most recent version in the repository mentioned in my comment above. The current state is as follows:
|
That sounds really good! For the question what is the best way to generate PDFs it is maybe worth to think about where this generation will actually happen in the end. I’m imagining two possible scenarios:
I'm imagining that in both scenarios, your code would only ever create the PDF for one tune at once, which can consist of one or more pages, but all in the same orientation. Generating a PDF containing multiple tunes can be handled by the RoR Sheetbook Generator, which already has the logic set up to combine different tunes that have different page orientations. If the "print to PDF" browser function works for the conversion from HTML to PDF, we can run it in a headless Chromium in the RoR Sheetbook Generator. Without having looked into it, I'm imagining challenges converting a sheet that looks good on screen into a PDF that is formatted properly will be:
These can surely be solved by postprocessing the PDF (challenge 2 could be solved by generating one PDF per page and then concatenating them in post). But for scenario 2 it would be good if we could solve them without postprocessing, so that the user can simply “print to PDF” the sheet directly from the browser. I don’t know if it’s possible, but I suspect not. An alternative for scenario 2 would be to send the JSON of the composed tune to a server and have the PDF generated there, then we are much more flexible. What exactly are the problems that you are facing regarding table borders in the printed PDF? Considering you are still working on your code, I would wait with my contributions until you have made some more progress. I could see my role in embedding the finished code into the RoR Player and the RoR Sheetbook Generator, and in refining the JSON format that finally will be the single source of truth for both the player and the sheetbook. One suggestion that I would have to make the code more readable would be to use a templating library such as EJS or Vue 3 rather than using the DOM API directly. |
Hm, today I tried to reproduce my problems with table borders in printed PDFs, but wasn't able to. It all looks fine today. I'm sorry for the confusion. I remember that, at some point, the borders would simply vanish in the PDF when selecting a small border-width, and the smallest possible border-width that would not vanish was quite fat and didn't look good. But, as I said, I'm now unable to reproduce this (at least with my current Firefox). I agree that we should only ever create the PDFs for individual tunes and continue using the sheetbook generator for more than that. And it's probably fine to rely on PDFs that we (pre-)generate in a server environment, instead of creating the PDFs on the client-side. So, yes, I will continue my work on the code, including translating everything to Vue.js. Usually I'm reluctant to use any external libraries since I don't quite like the node package ecosystem. Also, a JS project can get quite bloated really quickly when using JS frameworks. But since Vue.js is used in the RoR Player anyways, it should be fine to rely on it in this case. |
The sheetbook PDFs are currently generated from ODS files stored in the sheetbook repository. This approach has the following disadvantages:
Two ideas have come up to solve this:
I think the solution would be to define a more complex JSON model that is similar to the current model in the player but would contain a combination of musical instructions that can be interpreted by the player as well as layout instructions for the sheets. For example, the model should contain the following data:
Then some code needs to be written that generates the PDF files from the model. I think generating intermediate ODS files is not really necessary, since they are not used for anything. Some challenges that I expect during the PDF generation:
In a future iteration, the code could also decide the layout by itself, by trying out all the possible layouts and seeing which one wastes the least space and still fits a certain minimum font size.
The text was updated successfully, but these errors were encountered: