# Converting Windows Journal files to PDFs from command line

Support for the Windows Journal format (JNT) outside the Windows platform is dismal. Thus, I am looking for a way to convert jnt files to PDFs. Currently, one either has to print to PDFs from Journal or use online converters. Is there a way to automate the conversion?

-
Well if you're part-way there (via printing), you might be able to automate that process. – user3463 Jan 16 '11 at 0:16
Trouble is, the only PDF conversion printer drivers I have always pop up a "save as" dialog box and dong have command line interfaces. – Leo Alekseyev Jan 16 '11 at 0:54
Nah... some of these drivers have configuration options allowing to suppress the "Save as..." popup and use a default directory/name instead. – Kurt Pfeifle Jan 16 '11 at 12:06
Concrete examples?... CutePDF, for instance, doesn't have those options. – Leo Alekseyev Jan 16 '11 at 12:47
Use a combination of Ghostscript, RedMon and a generic PostScript printer driver and a batch file... See answer below. – Kurt Pfeifle Jun 2 '11 at 12:09

Look here:

REM Skript sthet unter GPLv3 by jcol11
REM man benötigt PDFCreator um es ausführen zu können

REM frisches Verzeichnis mit aktuellem Datum erstellen
rmdir %cd%\PDFs_%Date%
mkdir %cd%\PDFs_%Date%

REM alten Drucker umbenennen (keine Leerzeichen erlaubt)!!
REM HIER eigenen Standarddrucker eintragen merken
SET %alterdrucker=MeinDrucker

REM PDFCreator als Standarddrucker
rundll32 printui.dll,PrintUIEntry /y /n "PDFCreator"

REM Autosave aktivieren
REG ADD HKEY_CURRENT_USER\Software\PDFCreator\Program /f /v UseAutosave /d 1

FOR %%f IN (*.jnt) DO (
REM Filename setzen
REG ADD HKEY_CURRENT_USER\Software\PDFCreator\Program /f /v Autosavefilename /d %%f

REM Ausgabeverzeichnis setzen
REG ADD HKEY_CURRENT_USER\Software\PDFCreator\Program /f /v AutosaveDirectory /d %cd%\PDFs_%Date%\

REM PrintFile to pdf
"%ProgramFiles%\Windows Journal\Journal.exe" /p "%cd%\%%f")

REM alten Drucker wiederherstellen
rundll32 printui.dll,PrintUIEntry /y /n %alterdrucker%


Maybe you could improve my script and post it again? (new version under ubuntuusers available, works fine for me. It also saves the file under the correct filename):

Ubuntuusers.de Script to convert jnt to pdf

If you have improved the script please post it on ubuntuusers.de (you can post it in english). This will keep the "effort" together so that we dont have to check 2 sites for new versions.

-
Welcome to the site! Can you please summarize what the page says? It's in German, and I doubt everyone will understand what it does. It might be good to translate the script comments too. – slhck Dec 15 '11 at 20:02
This pointed me to the correct answer. I was able to write a cygwin script that is an equivalent of what john posted in the German Ubuntu forum. I posted it as a separate answer: superuser.com/a/369182/32247 – Leo Alekseyev Dec 18 '11 at 11:25

You could setup a print queue (that does not pop up a dialog for printing if you don't want to).

You can use a Ghostscript-based backend together with RedMon or RedMon 64bit and a generic PostScript printer driver to set up a printqueue that spits out PDFs if you print to it.

For details about the required setup procedure, see the RedMon documentation.

-

You should look to see what the DDE command is (if any) for Journal Viewer to print a file (such as when you right click a journal file and get a print option in the context menu). This is typically in the registry and might also be the "file type associations" table.

Once you have this info, you could set your pdf printer driver as default and then set a batch file to automate the pdf creation. With adobe PDF, you might have to specify a file name each time, which is suboptimal, but there are other options.

I do something similar for Word using command line options ( /q /n /a /mFilePrintdefault /mFileExit)

-

John's post pointed me to the correct answer. Here is a cygwin script that you can adapt to print the JNT files to PDFs using the PDF Creator (free Windows PDF printer). You might have to make sure that PDF Creator is installed, and is configured as the default printer (at least for JNT files).

#!/bin/bash

PDFDIR="pdfs"
JOURNAL_EXE="C:\Program Files\Windows Journal\Journal.exe"
AUTOSAVE_FNAME_FLAG="<REDMON_DOCNAME_FILE>"
PWD_CYGWIN_FORMAT="$(pwd -P)" PWD_WIN_FORMAT="$(sed -e 's|/|\\|g' \
-e 's|^.cygdrive.||g' \
-e 's|^$$.$$|\1:|g' <<< $PWD_CYGWIN_FORMAT)" AUTOSAVE_DIR_WIN_FORMAT="$PWD_WIN_FORMAT"'\'"$PDFDIR" # set up PDFCreator autosave REG ADD 'HKEY_CURRENT_USER\Software\PDFCreator\Program' /f /v UseAutosave /d 1 REG ADD 'HKEY_CURRENT_USER\Software\PDFCreator\Program' /f /v Autosavedirectory /d "$AUTOSAVE_DIR_WIN_FORMAT"
REG ADD 'HKEY_CURRENT_USER\Software\PDFCreator\Program' /f /v Autosavefilename /d "$AUTOSAVE_FNAME_FLAG" for file in *.jnt; do file_w_path="$PWD_WIN_FORMAT"'\'"$file" eval 'cygstart ''"'"$JOURNAL_EXE"'"'' /p '"'"'"'"\$file_w_path"'"'"'"
#strip 's cygstart   "  c:\prog...    "   /p   '  "  c:\home\...   "  '
sleep 0.5 # just in case
done


To use this script, put it somewhere in your PATH and execute it in a directory that contains the jnt files. It would be easy to modify it to take a target directory as a parameter.

Other notes: in theory, PDF Creator (free Windows PDF printer) should be able to generate the PDFs from the command line, but I couldn't get this to work. The crazy quoting in the eval statement simply produces cygstart "c:\program files..." /p '"c:\file\to\print"' on the command line.

-