Topics

Is There a Directive That Acts Like a Hyperlink? #ChordPro #needinfo


Alvin Tostig
 

Hello all.  I'm about a quarter of the way into my project of converting my 750-song, 1700-page songbook from MS-Word into ChordPro format.  I may not be using the most economical directives but so far it's going well and I don't mind the work.
 
I'm using the "chordii" default to generate a PDF that for the most part I'm happy with.  It automatically creates an alphabetical Table of Contents of song titles from the individual {title:} directive of each song and clicking/tapping on the song title takes you from the Table of Contents to the song.  My question is, is there a way to reverse this process and get from the song back to the Table of Contents without endless scrolling?  
 
I've currently got about 200 songs in the Table of Contents and nearly 500 pages in the body of the pdf.  When I'm finished playing a song on page 450 it'd be nice to have a "link" present to take me back to the TOC.  In MS-Word this is easily accomplished through the use of bookmarks and hyperlinks.  Is there a syntax/directive that would allow me to do the same in ChordPro?
 
My .txt file can be found at:  https://songbook19.my-free.website
 
Thanks (again) for the help.
 
Al
 


Johan Vromans
 

Great to hear you are making good progress!

As for the link back to the ToC I'm a bit puzzled. I could add something but every PDF viewer I know returns to the top of the file when I hit either [Home] or [Ctrl][Home]. Sounds easy enough.


Alvin Tostig
 

Well duh, you're absolutely right (shaking head).  In all honesty that (just hitting the Home key) never occurred to me.  As my pappy used to say, "The simplest solution is often the best."  Guess I couldn't see the forest for the trees.  Thanks, Al.


On Mon, Jun 29, 2020 at 2:28 AM Johan Vromans <jvromans+gio@...> wrote:

Great to hear you are making good progress!

As for the link back to the ToC I'm a bit puzzled. I could add something but every PDF viewer I know returns to the top of the file when I hit either [Home] or [Ctrl][Home]. Sounds easy enough.


itsme
 

How about generating PDF bookmarks?


Johan Vromans
 

Ah yes, we've had some discussions on this on the old mailing list. I think it is worth investigating.

What would you suggest?


Alvin Tostig
 

For Itsme:  I didn't know that was even possible.  I only have the free Acrobat Reader so most of my experience is "read only" when it comes to PDFs.  I think this is the case for many people (especially the technology-challenged like myself) who think if it's a PDF, open it with Acrobat.  I poked around my free version and did find the Bookmark function but it's greyed out and unavailable so I'm assuming it's only useable for a paid/subscription product.  Guess I could pony up and get a subscription.  Appreciate the suggestion. 
 
For Johan:  The PDF output of my Songbook is 1700 pages long and the ToC itself is (will be) about 30 pages long.  Using either the "Home" or even the "Go To" page function from deep within the PDF will indeed get users back to somewhere within the ToC but it would be nice if they could zero in back to the exact title.  I'd like to see a "Bookmark" directive that could be defined to a specific element (in my case "Title") that would generate a Bookmark icon, similar to how [G] produces a G chord diagram.  E.g.,
 
{ns}
{title: White Christmas - Bing Crosby}
{subtitle: (Irving Berlin)}
{artist: Bing Crosby}
{composer: Irving Berlin}
{define: F base-fret 1 frets x x 3 2 1 1} 
{capo: 0}    
{bookmark: title}
 
C    F                    G  
I'm dreaming of a white Christmas . . .
      C                         F                       G 
. . . and may all your Christmases be white.
 
 
<chord box C>      <chord box G>      <*chord box F>      <bookmark icon>
 
 
So in my world (and for my purposes) a bookmark would be linked to the title and a bookmark icon would be generated after the last chord box (or wherever really, just so it's identifiable).  And clicking/tapping on the icon would take the user back to the same song in the ToC.
 
Something like that.  Thanks for the opportunity to contribute.    -- Al    
 


Johan Vromans
 

There are several things being discussed here, and often mistaken. I'll to to isolate and clarify.

The links @itsme is talking about are hyperlinks (urls) to invoke e.g. a YouTube video or an external program like musescore. These links can be put in the PDF file. My question was to make a proposal of how such a link directive could look like, and how such a link appears in the PDF.

Alvin's bookmark question is basically 'how do I get back to where I came from'. Somewhere in the 30-page ToC you click a song and after playing it you want to get back to that location in the ToC again. It is technically possible to create such links but it is not trivial. Also, somehow it doesn't feel to be the right approach.

I did some research and the consensus seems to be that this is really a task for the PDF viewer program. Most of them maintain a view stack so that you can get back to the previous view with a click on a button. A fine example is MobileSheetsPro, that can import your PDF document together with a contents CSV and then you can jump back and forward between song view and contents view. To make importing easy ChordPro can generate this contents CSV for you while producing the PDF.


itsme
 

There are two separate topics we might talk about:
PDF bookmarks
are usually shown by PDF Viewers in a sidebar besides the PDF text and allow jumping directly to certain points within the PDF.
In case a PDF file contains bookmarks the according menu item is active, otherwise it is greyed out as Alvin noticed and mentioned in his post.
Hyperlinks
allow opening a different file with the respective program. This is only supported by only a few number of PDF readers.
In our case there could be a link in the PDF that opens the ChordPro version for the same song. This would indeed need further discussion.


itsme
 

Here's an example for Songbook ChordPro - F - 0626.pdf that I fiddled together using JPdfBookmarks. It is far from complete and works just for a few songs to demonstrate how PDF bookmarks look like.


itsme
 

Here's the PDF with added bookmarks if you want to try it in your favorite PDF reader. Most PDF readers support that.


itsme
 

I used LibreOffice Calc to collect and combine the data and export the input file Songbook ChordPro - F - 0626_Bookmarks.txt for JPdfBookmarks.
https://sourceforge.net/projects/jpdfbookmarks/files/
The format is specific for JPdfBookmarks.
It would be great if the Chordpro program could add bookmarks like that when creating the PDF output - similar to creating the TOC


itsme
 

I wrote a step by step description how to use a (MobileSheets specific) CSV file to add bookmarks to a PDF:
https://zubersoft.com/mobilesheets/forum/showthread.php?tid=5298


Johan Vromans
 

Attached a PDF with a couple of songs with bookmarks. No hierarchy, no sorting yet. I just want to make sure these are the bookmarks you talk about.


itsme
 

Exactly, That's what I'm talking about. But the page numbers look strange. Jumping to a page using the bookmarks shows a different page info compared to paging through the file page by page. This is not the case with my example above.


itsme
 

As a simple solution for a first attempt just provide the titles in the sequence of the songs 


Johan Vromans
 

This version should be better. It handles sorttitle and sortauthor as well.


Johan Vromans
 

Current dev has been comitted with the following config changes:

  	// Bookmarks (PDF outlines).
  	// fields:   primary and (optional) secondary fields.
  	// label:    outline label
  	// line:     text of the outline element
  	// collapse: initial display is collapsed
  	// letter:   sublevel with first letters if more
  	// fold:     group by primary (NYI)
  	// omit:     ignore this
  	"outlines" : [
  	    { "fields"   : [ "sorttitle", "sortartist" ],
  	      "label"    : "By Title",
  	      "line"     : "%{title}%{artist| - %{}}",
  	      "collapse" : false,
  	      "letter"   : 5,
  	      "fold"     : false,
  	    },
  	    { "fields"   : [ "sortartist", "sorttitle" ],
  	      "label"    : "By Artist",
  	      "line"     : "%{artist|%{} - }%{title}",
  	      "collapse" : false,
  	      "letter"   : 5,
  	      "fold"     : false,
  	    },
  	],


itsme
 
Edited

The new PDF looks great! Thank you.
Sorry that I don't have time to test the new version.
@Alvin Tostig: how about creating an updated version of your fakebook using the new dev version?


Alvin Tostig
 

I edited my JSON file with the new config changes . . . but not sure I did it right.  Attaching the PDF generated by ChordPro.  Looks the same to me but as I'm using Acrobat Reader "basic" with no bookmark capability I'm assuming it would.  -- Al.


Johan Vromans
 

You need the dev version for the outlines to work... Can you run from git (see https://www.chordpro.org/beta/chordpro-run-from-git/)?