Convert a Nxtbook Media Publication to PDF : The ARRL QST Magazine

posted in: Electronics, Radio Amateur | 0

Soon I will get my radio amateur license and I will be on the air DXing. Since I am interested to sneak peak electronics related to RF, I got register to the digital subscription of the America Radio Relay League ARRL so I could have access to the QST publication, very recomended for RF Freaks. www.arrl.com

I found the QST magazine very interesting, but there was a negative thing about it; they only offer an offline version of the magazine that it is contained in a “EXE” software, I know that they also offer an Android and Iphone versions, but doesn’t help me at all. So, if you use the EXE application and try to print it in PDF, they reduced the quality of the text and images, and also they only allow you to print in batches of 20 pages every time…. AGGGRRRRRR not very nice from them. I don’t understand why they don’t supply with a proper PDF file for those who have an Ebook Reader like me. I love to download my digital subscriptions in the ebook, grab a coffee and have a nice time.

I found two solutions in order to get a high quality PDF from this magazine, so if your are interested keep reading! Both solutions are done with a computer running windows

Solution 1

If you download the first off-line magazine from QST, the 2012 January QST. With this version you can print PDF with high quality image and attached fonts, but they have limit the number of pages that you could print at once, they limited to around 20 :(. Anyway, I use this old version to print newer versions of this magazine, of course a bit tedious but the result it is the best!

So you could download the 2012 01 version and the version that you want to print, install both versions in your computer. For the newer magazine, you will have to find the “highres” folder inside the QST folder, in my case was located in “C:\Program Files (x86)\arrl\qst\arrl_qst_201411\nxtbook\highres”. After, you will have to rename the “highres SWF” files to match the QST 201201 version, so you can open the new magazine with the old version software.

To automatically change the name of the files, you have a script that do it automatically for you. Copy the following text into a txt file, then save it as “RenameQSTFiles.bat”. Copy the BAT file into the new magazine “highres” folder and double click to execute it. All the files should be renamed to something like “arrl_qst_201201_p0xxx.swf”.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@echo off
SetLocal EnableDelayedExpansion
 
set Num=0
for /f %%a in ('dir /b arrl_qst_*.swf') do (
    set /a Num+=1
    if !Num! LSS 1000 set S=0!Num!
    if !Num! LSS 100 set S=00!Num!
    if !Num! LSS 10 set S=000!Num!
    if !Num! LSS 10 (
        ren %%a arrl_qst_201201_p!S!.swf
    ) else (
        ren %%a arrl_qst_201201_p!S!.swf
    )
)

Then you will have to select all the high SWF files, then copy them to the “highres” folder of the 201201 QST magazine, of course you should replace the files. After this you could execute the 2012 magazine and use the print button to print the pages. You will need to print the pages in batches, because they limit the maximum number of pages to print. I found if after printing you close the application and started again, you could print around 25 pages, if not the limit goes below 10. To join all the documents together I used a function located in “tools>Inser from file” inside Adobe Acrobat (Editor ver), and you have your nice PDF document in high resolution.

This was my first approach to convert the magazine until I discover that someone has implemented a Python script to do this, YEAH! This other solution

Solution 2

This solution is based in a Python script found at http://development.genusa.com/converting-a-nxtbook-media-digital-publication-to-pdf/ developed by Stephen Genusa, with some minor modifications that I have to do to make it work in my computer. All the credit goes to the author of the script, I just made some modifications ;). This solution executes automatically and you dont have to do much, the negative part it is that the script generated PNG files for each page and at the end join them in one PDF doc, so the file it is a bit bigger and you can not select the text because it is a picture based pages.

First, you will need to download and install: Phyton, SWFTools and ImageMagick. Also copy the following code and save it in a TXT file with the name “ConvertNTXBook.py”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
# May 2012 by Stephen Genusa http://development.genusa.com
# October 2014: Modifications by Freakyattic.com
#
# Written for Python 2.7x
#
# Commandline param required: the book.xml file of the digital publication
#
import xml.dom.minidom
import os, sys, codecs
 
intPages = 0
t_booktitle = ""
ImageMagicFolder = "C:\Program Files\ImageMagick-6.8.9-Q16"
SWFToolsFolder = "C:\Program Files (x86)\SWFTools"
 
def getText(nodelist):
	# Transform nodelist into text if TEXT_NODE elements exist in nodelist
	rc = []
	for node in nodelist:
		if node.nodeType  == node.TEXT_NODE:
			rc.append(node.data)
	return ''.join(rc)
 
def handlePage(page):
	# Process individual pages
	t_id = page.getAttribute('id')
	t_filename = page.getElementsByTagName('file')[0].getAttribute('value')
	t_filename = t_filename.replace("/", "\\")
	t_fullpath = os.path.dirname(sys.argv[1]) + "\\" + t_filename
	t_conversionparams = ' -X2880 "' + os.path.realpath(t_fullpath) + '" -o Filespage' + str(intPages).zfill(3) + '.png'
	print t_id, " ", t_filename
	print t_conversionparams
	print
	os.spawnl(os.P_WAIT, SWFToolsFolder + "\swfrender", t_conversionparams)
 
def handlePages(pages):
	# Convenient "for loop" to loop through page elements
	global intPages
	print 'Processing', len(pages), 'pages ...'
	for page in pages:
		intPages += 1
		handlePage(page)
	print 'Finished Processing', intPages, 'pages ...'
	t_conversionparams = 'Files*.png "' + t_booktitle + '.pdf"'
	os.spawnl(os.P_WAIT, ImageMagicFolder+ "\convert", t_conversionparams)
 
def ReadNxtbookXMLFile(strFileName):
	global t_booktitle
	if os.path.exists(strFileName):
		t_dom = xml.dom.minidom.parse(strFileName)
 
		t_contents_items = t_dom.getElementsByTagName('contents')[0].getElementsByTagName('item')
 
		filBookmarks = codecs.open("bookmarks.txt", encoding='utf-8', mode='w+')
 
		for item in t_contents_items:
			t_bookmarktext = item.getAttribute('text')
			t_bookmarktext = t_bookmarktext.replace("&", "&")
			t_pagenum = item.getAttribute('folio')
			t_pagenum = t_pagenum.replace("Cover", "")
			filBookmarks.write(t_bookmarktext + '/' + t_pagenum + "n")
		filBookmarks.close()
		print "Bookmark file written"
 
		t_booktitle = t_dom.getElementsByTagName('book')[0].getAttribute('title')
		t_booktitle = t_booktitle.replace('+', ' ')
		handlePages(t_dom.getElementsByTagName('page'))
		t_conversionparams = ' Files*.png "' + t_booktitle + '.pdf"'
		#print t_conversionparams
		print "Converting the PNG files to PDF. It may take some time, wait ..."
		os.spawnl(os.P_WAIT, ImageMagicFolder+ "\convert", t_conversionparams)
		#t_conversionparams = "--apply input.pdf bookmarks.txt output.pdf"
		#os.spawnl(os.P_WAIT, "c:\program files\jpdfbookmarks\jpdfbookmarks", t_conversionparams)
 
# ------------------------------------------------------------------------------------
#  Actual Script, the previous are functions ;)
# ------------------------------------------------------------------------------------
ReadNxtbookXMLFile(sys.argv[1])

In this document you will have to modify the line number 14 and 15 with the current path of the software in your computer, if not you will get errors because the script can not find the software.

To launch the script you only need to open a console window and write the following comand  “<path>ConvertNTXBook.py  <QST_Path>\book.xml”. In my case I used the following command

 ConvertNTXBook.py C:\Program Files (x86)\arrl\qst\arrl_qst_201412\nxtbook\book.xml

The script will convert each page and at the end put them in a PDF file, give it some time, it is a bit slow 😉