External File Conversion

The purpose is to call on another program to convert the output of a LifeLines report program. Currently, this feature is available in recent interim versions of ps-anc.

This feature first appeared in version 8.80 of ps-anc. One additional idea is to add a computing "platform" or "OS" option to choose between different built-in conversions. This will definitely be an area where user-customization will be necessary.

Details

In the beginning there was just this code just placed after the call to "print_file" at the end of the "main" procedure:

    /* apply external file conversion command */
    newfile(outfile(), TRUE)  /* trick to force writing of output buffer */
    system(concat("ps2pdf ", outfile()))
Which only assumes you have a PostScript to PDF conversion program (or shell script) called "ps2pdf".

Then a few choices were provided (some platform dependant).

    /* apply external file conversion/viewing command */
    newfile(outfile(), TRUE)  /* force flush of output buffer */

    list(actions)
    list(choices)
    enqueue(choices, "View with MacGhostViewX")
    enqueue(actions, concat("open ",
      "/Applications/MacGhostViewX/MacGhostViewX.app ", outfile()))
    enqueue(choices, "Convert with 'ps2pdf'")
    enqueue(actions, concat("ps2pdf ", outfile(),
      " `echo ", outfile(), "|sed 's:\.ps:\.pdf:'` && rm -i ", outfile() ))
      /*
         The command used above will put the PDF output in the same
         location (directory) as the original PostScript output.
      */
    set(mc, menuchoose(choices, "Choose an action or (q)uit to leave as is"))
    if(mc) {
      print("performing: ", getel(actions, mc), nl())
      system(getel(actions, mc))
    }
Of course, for these to work it is necessary to install Ghostscript (for any platform). MacGhostViewX is a Mac OS X postscript viewer. Comparable programs exist for other platforms.

Part of a Ghostscript installation is the script ps2pdf that will call ghostscript with the right options to effect a ps-to-pdf conversion.

See my readers page for information on installing Ghostscript.