+ (if (module? header)
+ (begin
+ (display "mark " port)
+ (metadata-lookup-output 'pdfauthor 'author "Author")
+ (format port "/Creator (LilyPond ~a)\n" (lilypond-version))
+ (metadata-lookup-output 'pdftitle 'title "Title")
+ (metadata-lookup-output 'pdfsubject 'subject "Subject")
+ (metadata-lookup-output 'pdfkeywords 'keywords "Keywords")
+ (metadata-lookup-output 'pdfmodDate 'modDate "ModDate")
+ (metadata-lookup-output 'pdfsubtitle 'subtitle "Subtitle")
+ (metadata-lookup-output 'pdfcomposer 'composer "Composer")
+ (metadata-lookup-output 'pdfarranger 'arranger "Arranger")
+ (metadata-lookup-output 'pdfpoet 'poet "Poet")
+ (metadata-lookup-output 'pdfcopyright 'copyright "Copyright")
+ (display "/DOCINFO pdfmark\n\n" port)))
+
+ (if (ly:get-option 'embed-source-code)
+ (let ((source-list (delete-duplicates
+ (remove (lambda (str)
+ (string-contains str
+ (ly:get-option 'datadir)))
+ (ly:source-files)))))
+ (display "\n/pdfmark where
+{pop} {userdict /pdfmark /cleartomark load put} ifelse" port)
+ (for-each (lambda (fname idx)
+ (format port "\n
+mark /_objdef {ly~a_stream} /type /stream /OBJ pdfmark
+mark {ly~a_stream} << /Type /EmbeddedFile>> /PUT pdfmark
+mark {ly~a_stream} (~a) /PUT pdfmark
+mark /Name (LilyPond source file ~a)
+/FS << /Type /Filespec /F (~a) /EF << /F {ly~a_stream} >> >> /EMBED pdfmark
+mark {ly~a_stream} /CLOSE pdfmark
+\n"
+ idx idx idx
+ (ps-quote (ly:gulp-file fname))
+ idx fname idx idx))
+ source-list (iota (length source-list))))))