Creating a pdf using script
Suppose I have an XML file. Is there a way to convert this programmatically to a PDF? I.e. in jscript or javascript or the like?
Thanks
Suppose I have an XML file. Is there a way to convert this programmatically to a PDF? I.e. in jscript or javascript or the like?
Thanks
Do you still have an unanswered question? Please log in first to post your question.
Comments
Open with MuseScore and Export as PDF should work (perhaps not what you are looking for?)
In reply to Open with MuseScore and by Shoichi
no - I do use this, but it is a manual process. With 1000 xml files I am looking for an automated solution.
mscore foo.xml -o foo.pdf
In reply to mscore foo.xml -o foo.pdf by Marc Sabatella
this looks promising. A batch process would be useful. Is this a DOS command running an exe? Does it exist? I don't see it as an executable.
In reply to this looks promising. A batch by Bob MacDonald1
Yes it is, but under Windoes it is "MuseScroe.exe" rather than "mscore", see https://musescore.org/en/handbook/command-line-options-0 for the Options and Syntax available.
Also check the Batch Convert plugin , it should do this for you automagically.
You may also want to look at https://musescore.org/en/node/12452
In reply to Yes it is, but under Windoes by Jojo-Schmitz
I enabled the plugin
I selected a folder one of many in a hierarchy. I first set the conversion from .XML to .pdf
I may have forgotten to unclick .mscz
There were many files in this folder. It appeared to do all the files in all the folders at the same level of the main folder. There were several that were error-prone since they were done in Musescore 1 and I had to answer the yes no etc one at a time. I could put up with that but I would have preferred to say do this for all errors in this run.
Then I noted that no .XML files were converted. In fact it cannot find files with a capitalized file name of .XML
I could rename them all I suppose, but Musescore reads them fine as CAPS.
thanks - I see there are possibilities here.
Bob
In reply to I enabled the plugin I by Bob MacDonald1
The plugin should recure into subdirectories only if explicitly told to (i.e. the corresponding Checkbox is ticked) and as Windows is not case-sensitive (just case-preserving), the plugin shouldn't either. It does though, strange, looking into this...
Ignoring errors sounfs like a nice extension, not sure though the plugin framework allows for that, but indeed having unchecked .mscz should have sorted that for you ;-)
In reply to The plugin should recure into by Jojo-Schmitz
The fix for uppercase XML is quite easy, just Change the line 409 in batch_convert.qml from
if (inXml.checked) inFormats.extensions.push("xml")
to
if (inXml.checked) inFormats.extensions.push("xml", "XML")
and, strange enough, we did that for the mgu and sgu formats. I wonder whether there is a more elegant solution to this.
Anyway, that simple fix is online now.
EDIT: I just found a much better solution, I changed line 490 from
if (inFormats.extensions[i] == suffix) {
to
if (inFormats.extensions[i].toUpperCase() === suffix.toUpperCase()) {
with the Advantage that it now takes mixed case too. Will be online shortly.
In reply to The fix for uppercase XML is by Jojo-Schmitz
I will look forward to your changes. I am not set up to change .js files
In reply to I will look forward to your by Bob MacDonald1
Just download again and replace your current files.
In reply to Just download again and by Jojo-Schmitz
Thanks
I did download - still gives no files found message for .xml.
I can't read the .md file. A search for xml in the files does not show an to upper function applied.
I am away for a while and will try again later.
I found the code and the toUpper function and this is definitely the right version. Still trying to make it work
In reply to Thanks I did download - still by Bob MacDonald1
When I choose the parent directory it works fine
When I chose just a single directory it gave no files found. Anyway - the job is now processing - thanks very much for your help
In reply to When I choose the parent by Bob MacDonald1
Processing finished
A half dozen of the 1000 files would not read without a 'yes' to a yet undiagnosed error - but I got through them
then I recursed a directory that had the java development kit in it with 10000s of xml files - no escape so I had to bring up task manager to kill the app. I think having a do you want to continue or do you want to ignore all subsequent errors is probably important :)
thanks again - all done for now.
Hi again
I have this structure directory main and 40 subdirectories
If I chose a subdirectory and recurse the directories, then all subdirectories are processed.
That's how it worked a few days ago - it didn't seem quite right but it worked.
Now I have to update a half-dozen of the 935 xml files
So the new ones go to my download directory which has in it a subdirectory I don't want to process and I can't move it since I am executing an oracle program there (another problem but not related)
I reexecute the batch convert
I pick downloads and it says it cannot find any files
I try renaming one file to .xml (they are all in caps) and it still cannot find files
I put them in a subdirectory and select that and it still finds no files in the subdirectory but it did find 3 files that were in the main downloads directory. I.e. when I pick a directory, it seems to process the parent of the directory that is picked and not the directory I select.
To prove this I created a dummy directory (empty) in downloads and pick 'dummy' in the batch file select directory dialogue. All the files process, that are on the same level as as the empty dummy directory. Recurse directories is not enabled. Just xml to pdf processing.
This is a bit counterintuitive but I now know how to make it work.
I would expect that I would pick the directory that contains the files I want to convert, not the directory that is at the same level as the files I want to convert.