Reported by Samuel Da Mota on Lilypond user here:
http://lists.gnu.org/archive/html/lilypond-user/2012-07/msg00105.html
Hi,
I'm a pretty much new user of lilypond and I have an idea for a almost dummy new feature: automatically attach lilypond code in pdf. With pdf files it is possible to attach a file into it. I think it would be nice to have a lilypond option that attaches the .ly files into the pdf. This way when someone creates a partition and upload it to a website, the code will be uploaded too, thus making it much more easier for any user to possibly modify it. Moreover it will help spreading the use of lilypond.
In linux it is easy to do it using pdftk (the command is "pdftk input_file.pdf attach_files source_file.ly output output_file.pdf"). It may be interesting to automatically call this command just after the pdf generation. Pdftk seems to be also available under windows and mac os.
Moreover, if this feature is accepted, it may be interesting to modify the default tagline which says "engraved by lilypond version x.y.z" to "engraved by lilypond version x.y.z with source file attached" to increase its visibility.
Of course, for musicians who doesn't want to share their lilypond code, this feature should be kept as an option (maybe turned on by default).
Best Regards,
Samuel DA MOTA
Comment #1
Posted on Jul 14, 2012 by Swift OxAccording to the following discussion, you can use the /pdfmark postscript command to attach files: http://forums.adobe.com/message/4438533
A sample eps file (hand-written text file) is attached, to create the pdf, you need to run ghostscript with the -dNOSAFER option to allow file access: ps2pdf -dNOSAFER test.eps
The resulting pdf file correctly shows the attachment in acroread. However, neither okular nor evince are able to detect the attachment, only acroread does.
More information about the file attachment subtype of the pdfmark command can also be found on page 488 of http://www.dpunkt.de/leseproben/1360/Kapitel_11.pdf
- test.eps 559
Comment #2
Posted on Apr 3, 2015 by Helpful BearHere’s a patch that more or less implements that feature (although it doesn’t create a compressed archive when there are multiple files).
Comment #3
Posted on Apr 4, 2015 by Quick Kangaroo(No comment was entered for this change.)
Comment #4
Posted on Apr 4, 2015 by Quick KangarooPasses make, make check and a full make doc.
reg test shows up
--snip--
input/regression/option-help.log
@@ -34,6 +34,7 @@ dump-profile (#t) Dump memory and time information for each file. dump-signatures (#t) Dump output signatures of each system. Used for regression testing. + embed-source-code (#f) Embed the source files inside the generated PDF document. eps-box-padding (3.0) Pad left edge of the output EPS bounding box by given amount (in mm). gs-load-fonts (#f) Load fonts via Ghostscript.
--snip--
James
Comment #5
Posted on Apr 6, 2015 by Quick KangarooPatch on countdown for April 9th
Comment #6
Posted on Apr 6, 2015 by Helpful Bear(Syntax consistency nitpick)
Comment #7
Posted on Apr 7, 2015 by Quick KangarooPatchy the autobot says: passes tests. Includes a full make doc
Comment #8
Posted on Apr 9, 2015 by Quick KangarooPatch on countdown for April 12th
Comment #9
Posted on Apr 10, 2015 by Helpful BearSome improvements (but problems still exist)
Comment #10
Posted on Apr 10, 2015 by Helpful BearUse mark _ pdfmark instead of [ __ pdfmark
Comment #11
Posted on Apr 10, 2015 by Quick KangarooPatchy the autobot says: passes tests. Includes a full make doc
Comment #12
Posted on Apr 11, 2015 by Helpful BearRetrieve source file paths directly from Includable-lexer:: class
Comment #13
Posted on Apr 12, 2015 by Quick KangarooPatchy the autobot says: passes tests. Includes a full make doc
Comment #14
Posted on Apr 12, 2015 by Helpful BearThe current patch is broken, but it’s sorta by design (see my last comment on Rietveld).
Comment #15
Posted on Apr 12, 2015 by Quick LionI'll take a look eventually but right now I'm half through the alphabet on that other patch...
Comment #16
Posted on Apr 15, 2015 by Quick KangarooPatch on countdown for April 18th
Comment #17
Posted on Apr 18, 2015 by Quick KangarooI'm going to leave this on 'countdown' for April 21 as it seems there is still some discussion here.
Comment #18
Posted on Apr 21, 2015 by Quick KangarooNothing has moved on - leaving on another countdown for April 24th - if I still see no change, I'll put this back to review.
Comment #19
Posted on Apr 21, 2015 by Helpful BearOh, it’s definitely on review, since it just isn’t working at the moment (ever since David made me add a "parser" arg that I’m not sure how to retrieve, cf the FIXME line #420 in framework-ps.scm).
For now, setting -dembed-source-code will make Lily crash, which is not ideal.
And while we’re at it, I’m not sure how to add a regtest for this feature: ideally we’d need something that checks the created PDF for an embedded file, extracts it and compares it to the source file (they should be identical).
Comment #20
Posted on Apr 21, 2015 by Quick LionSorry, I am currently quite immersed in issue 1375 or probably rather a precursor of it (issue 4351 is already a bit of lead-up work). I'll get back to this one once I can find sufficient focus.
Comment #21
Posted on Apr 24, 2015 by Quick KangarooLeaving on review for now
Comment #22
Posted on Apr 27, 2015 by Quick KangarooDavid, do you still want me to leave this on Review?
Comment #23
Posted on Apr 27, 2015 by Quick LionAs far as I can tell from Valentin's own comments, this does not currently work properly and my attention is required. So I'm afraid that it will need to stay on review right now. Sorry for that. I'm making progress on the stuff currently occupying my mind though, so I hope I'll be able to get to this here this week.
Comment #24
Posted on Apr 30, 2015 by Quick KangarooKeeping on Review
Comment #25
Posted on May 3, 2015 by Quick KangarooKeeping on Review still
Comment #26
Posted on May 6, 2015 by Quick KangarooStill keeping on review until I hear different from David K - as he asked for time in comment #23 and I don't see anyone clamouring for this patch to be pushed
Comment #27
Posted on May 6, 2015 by Quick KangarooStill keeping on review until I hear different from David K - as he asked for time in comment #23 and I don't see anyone clamouring for this patch to be pushed
Comment #28
Posted on May 9, 2015 by Quick KangarooStill keeping on review until I hear different from David K - as he asked for time in comment #23 and I don't see anyone clamouring for this patch to be pushed
Comment #29
Posted on May 12, 2015 by Quick KangarooDo I still keep on review or move to 'waiting'? Although I forget why people wanted me to keep the 'waiting' patches listed - but that's not important.
Comment #30
Posted on May 12, 2015 by Quick LionCurrently "waiting". I've started taking a look but, uh, it is quite more tricky than I tried selling to Valentin.
And we don't want to expose absolute paths in the attachments while they might be required for actually getting the files.
Comment #31
Posted on Jun 11, 2015 by Quick LionValentin?
The parser can now be retrieved in Scheme as (parser) and in C++ as
scm_fluid_ref (ly_lily_module_constant ("%parser"))
at the point of use (don't try storing it somewhere).
This involved several issues, most notably issue 4422. Hopefully this is the missing piece of the puzzle.
Comment #32
Posted on Jun 11, 2015 by Helpful BearYep; this should make things easier indeed. I’ll have a look, thanks for the ping!
Status: Started
Labels:
Type-Enhancement
Patch-waiting