On Fri, 2022-02-11 at 09:49 +0000, Joe Wilkinson wrote:
> Hi Richard,
> I've just tried it out on a 128 measure piece.
> It works fine though, as you say, it would be nice if 
>  * it could print out different parts with different score sizes
> (could be difficult)
>  * if the score size chosen wasn't always the last one
>  * if the individual parts could start on a new page, and
>  * if the version didn't get printed out for each part, in a stack!

All of these (except perhaps the last) are not possible at present with
LilyPond (*) so I have created a way to do this from Denemo.
Attached is a Scheme script which allows you to create a "Book"
comprizing various layouts which the command will combine together as a
final PDF. You have to invoke the command once for each layout you want
to include in the book.
It is quite clunky but I think it is working - if you can test it out
on Windows that would be helpful.

Richard
(*) I asked on the LilyPond mailing list 
https://lists.gnu.org/archive/html/lilypond-user/2022-02/msg00247.html

and it is a deep-rooted problem :(

;;;;;CreateBook
(define-once CreateBook::page-start 0)
(define-once CreateBook::pdfs "")

(let ( (tag "CreateBook") (choice 
	(RadioBoxMenu (cons (_ "Add Current Layout to Book") 'add)
					(cons (_ "Create PDF from Book") 'create)
					(cons (_ "Start a new Book") 'new))))
	(define (create-pdf)
			(let* ((basename (tmpnam))
							(lilyfile (string-append basename ".ly")))
						(set! CreateBook::pdfs (string-append CreateBook::pdfs " " basename ".pdf"))
						(d-ExportMUDELA lilyfile)
						(d-WarningDialog (_ "Click \"Close\" and this dialog will freeze until the typesetting is done\nSorry this is so clunky!"))
						(d-CreatePDFFromLilyfile lilyfile basename)
						(d-InfoDialog (_ "Now typeset further layouts and run the command again to add them to the book or to finalize the book"))
						(set! CreateBook::page-start (+ 1 CreateBook::page-start (d-GetNumberTypesetPages)))))						
	(case choice
		((add)  
				(if (zero? CreateBook::page-start)
					(create-pdf)
					(begin
						(d-DirectivePut-paper-postfix tag (string-append "\nfirst-page-number = " (number->string CreateBook::page-start) "\n"))
						(create-pdf)
						(d-DirectiveDelete-paper tag))))		
		((new) 
				(set! CreateBook::page-start 0)
				(set! CreateBook::pdfs ""))
		((create)
				(if (string-null? CreateBook::pdfs)
					(d-WarningDialog (_ "You must add layouts to the Book first"))
					(let* ((name (d-GetUserInput (_ "Create Book") (_ "Give name for PDF:") "DenemoBook")) (output (d-PathFromFilename (d-Open "query=filename")))
							(command (if output (string-append "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=\"" output "/" name ".pdf" "\"" CreateBook::pdfs) #f)))
						(if command
							(system command)
							(d-WarningDialog (_ "Score saved to disk"))))))))

Reply via email to