The VitalSource Bookshelf software allows you to print your book, but only 5 pages at a time. On the surface this would seem to foil the print-to-PDF method, however using some AppleScript magic we can have their own software do all the work for us
You will need a computer running MacOS in order to do this, however the resulting PDF will work on any computer. There are VMWare images of MacOS available online if you don't have a Mac. The AppleScript code below will dump the entire ebook out into a bunch of pdfs, each containing 5 pages each. We can then easily merge them together to create one DRM-free PDF containing all the pages.
- Open your ebook up in the VitalSource app.
- Load up AppleScript and paste in the following code:
Code:
set totalPages to 340
set startPage to 0
set authorName to "DMT"
tell application "VitalSource Bookshelf"
activate
repeat with theIncrementValue from startPage to totalPages - 1 by 5
if (theIncrementValue = 0) then
set thisValue to "a"
else
set thisValue to theIncrementValue
end if
tell application "System Events" to keystroke "p" using command down
tell application "System Events" to keystroke thisValue as string
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke theIncrementValue + 5 as string
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke return
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "p" using command down
tell application "System Events" to keystroke theIncrementValue as string
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke authorName
tell application "System Events" to keystroke return
delay 7
end repeat
end tell
Did you notice how we even took away the sides of our sexy ASCII art just so you would have hassle-free copy+paste?
- Change the totalPages to the number of pages, and authorName to whatever you want that field set to in the pdf.
- The delay of 7 seconds is quite conservative, this should do nicely for most people. If your computer is really fast then you can probably lower it a bit, but if the saving of any one pdf takes more than the delay then the script will break and you'll have to manually stop it. If this happens just set the startPage to the Next page you don't have. Pages are saved starting from 0 (page 0 is called "a" in the app, fuck knows why) and up in increments of 5, so you'll end up with 0.pdf, 5.pdf,10.pdf, etc etc. So if it breaks and you have to re-start it, the number you start it from will always be either 0 or a multiple of 5.
- So now you have your pdfs, time to join them together. If you want to do this on MacOS, install the textlive-context port with:
Code:
# port install texlive-context
If you want to merge them on a ubuntu or debian linux box, then you want to do:
Code:
# apt-get install context
Make sure all the pdfs are in one directory, then cd into that directory and type:
# texexec --pdfarrange --result all.pdf `ls -1 *.pdf |sort -n`
This will get you a low quality .pdf file with a disclaimer at the top of every page.