Showing posts with label publishing. Show all posts
Showing posts with label publishing. Show all posts

Wednesday, 3 December 2014

Don't be illl (sic)

The danger of lapsing into sickness.

We think one small affliction will do us no harm, and maybe even some good - but then we find it becomes habit forming and we can hardly manage to get well again.


Consider the virtue of procrastination. Why get sick today if you can be sick tomorrow - or even next week!

Even better, make it a new years resolution and put it off for years. If you can procrastinate sickness, then maybe try to put off that final exit from life!

You know it makes sense!

Saturday, 10 September 2011

LDS Hymns in PDF form for service programmes

When producing a printed order of service it is traditional as well as convenient to include hymns in the printed programme.

This requires a source of the typeset hymns to insert into the programme.

Unfortunately there is no simple and convenient online digital source of typeset hymns that I am aware of.

There is not even PDF format LDS Hymn Book - if there was I could render the PDF as a bitmap (or convert to postscript) and embed it in the programme.

The closest and most convenient source is the online hymn book at http://hymns.lds.org which is driven by flash.

Fortunately it allows printing of the hymns (most of them) - but don't use your web browsers print option, use the "Print Song" option within the hymn player.

The hymns can be printed, and if you have a PDF printer driver installed you can produce a PDF.

The typeset hymn is represented in the PDF as a set of tiled bitmaps.

The following bash script will take such a PDF, extract out the tiled bitmaps, assembled them into one large png with borders cropped.

This png is then suitable for including into service programmes.

I usually edit the png to bring the hymn number down to the same line as the title, and the tempo up to the same line as the title, and also to reduce the space required by the copyright notice at the bottom of the page - this brings the png to the aspect ratio of an A4 (or A5) page allowing it to show full size - and is a requirement if all of the horizontal lines on the stave are to print properly.

#! /bin/bash

# Author: Sam Liddicott - This is dedicated to the public domain
# Usage: hymn2png print-to-file.pdf
# and produces print-to-file.pdf-1.png, print-to-file.pdf-2.png
#
# Although this is a bash script I tried to write it in LISP style
# hence the use of eval. I try to avoid most of the sin of eval
# by using it only to call another function but I guess it still
# breaks on file names with spaces in

get_row() { # page row
  pnmcat -white -leftright <( pngtopnm "$datadir/p-$1_$2.png" ) \

                           <( pngtopnm "$datadir/p-$1_$(($2 + 1)).png" )
}

get_next_row() { # page row
  if test -r "$datadir/p-$1_$2.png"
  then echo "<( get_row $1 $2 )"
       get_next_row $1 $(($2 + 2))
  fi
}

get_page() { # page
  eval pnmcat -white -topbottom $( get_next_row $1 1 )
}

get_next_page() { # page
  if test -r "$datadir/p-$1_1.png"
  then get_page $1 | pnmcrop -white | pnmtopng > "$file-$1.png"
       get_next_page $(($1 + 1))
  fi
}

file="$1"
datadir="/tmp/$USER-$file.data"
mkdir -p "$datadir"
trap "rm -fr $datadir" EXIT

pdftohtml "$file" "$datadir/p.html"
get_next_page 1


EDIT: I try some other google terms and discover here http://hymnwiki.30302.n2.nabble.com/I-d-like-to-contribute-Lilypond-source-pdfs-of-recent-LDS-hymnbooks-td4989774.html that there is a PDF of the Hymn Book http://lds.org/cm/pdf/Hymns_1-341_OneFile_pdf.zip and the Primary Song book http://lds.org/cm/pdf/ChildrensSngbk_Pages1-299_pdf_eng.zip.

This hymn book is vector form and so should scale better.
I print-to-file the page I want, and then convert that page to svg using pdftosvg.
I then edit the svg in inkscape and clip to a smaller size, and save-as .eps
I then insert the eps into libreoffice/openoffice documents and it prints very fine indeed.

Saturday, 2 May 2009


About a year ago I was called as second councillor to the Bishop in Wakefield Ward.

One of my responsibilities is to arrange the meeting programme and to give out speaking assignments, and then conduct the meeting for four months of the year.

I like to be well prepared for things which would otherwise be embarrassing, so to help me I produced an open office writer template that has four pages.

The first page is a meeting programme, with some grey fields to be filled in with things like,
  • the date and meeting type
  • the person conducting the meeting
  • the speaker names and topics, and duration etc.
By filling this in I get a regularly formatted meeting programme which helps me when conducting the meeting.


The bonus, however, is pages 2-4, which are speaker assignment letters and are automatically filled in for me. They inform each of the speakers of
  • the date and topic
  • how long they should plan to speak for and at what time they should finish
  • what other topics will be addressed in the same meeting
  • some tips on good preparation
  • who to contact for further information
So I write out the meeting programme and the computer generates a helpful invitation letter which I can edit if particular speakers need additional information or encouragement.

And I hit print!

Recently the template broke because I used a variable date internally which now (I guess) seems to conflict with some changes in OpenOffice 3. As OpenOffice documents are zip files, the simplest fix was to unzip the template and do a search and replace on the document xml, to replace date with mdate:

$ mkdir t
$ cd t
$ unzip ../vSacrament\ Meeting\ Assignments.ott
$ sed -i -e 's/name="date"/name="mdate"/g' content.xml
$ zip -r ../x.odt .


And then open and re-save the document in OpenOffice