Typesetting a novel for Print with HTML & CSS Paged Media

I’ve been fol­lo­wing new deve­lop­ments around CSS Paged Media and PrintCSS for a whi­le now. I never had the chan­ce to test them out in a real word pro­ject. Until recent­ly. The publis­hing hou­se I work for wants to pro­du­ce per­so­na­li­zed novels. Cust­o­m­ers can cust­o­mi­ze (*badum *tsch) their novel in a web fron­ted writ­ten in Python. The out­put is plain HTML5.

To avo­id over­head I set out to type­set the dif­fe­rent novels with web tech­no­lo­gies. The­se are my fin­dings:

tl;dr: It pret­ty much went smooth­ly. CSS Paged Media is even more con­ve­ni­ent than InDe­si­gn in some aspects.
Docrap​tor​.com (with Prin­ce XML as the engi­ne) was my Con­ver­ter of choice.
I would only wish for one mis­sing fea­ture, other­wi­se type­set­ting was a bree­ze.

Type­set­ting a novel for Print with HTML & CSS Paged Media wei­ter­le­sen

Building Softcover on Mavericks (Soft​co​ver​.io)

TL;DR:

To install soft­co­ver on mave­ricks use the Fol­lo­wing com­mand line string:

 sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install softcover

Long Version:

I stum­bled over soft​co​ver​.io and imme­dia­te­ly tried to install on my machine, which is run­ning OSX 10.9.2 (Mave­ricks).

I used:

$ sudo gem install softcover

to start the soft­co­ver instal­la­ti­on. To my disap­point­ment the instal­la­ti­on pret­ty much cras­hed right from the start:

sudo gem install softcover
Building native extensions. This could take a while...
ERROR: Error installing softcover:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [generator.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.1/gem_make.out
georgs-imac-2:~ shorshe$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future sudo gem install softcover
Building native extensions. This could take a while...
ERROR: Error installing softcover:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [generator.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.1/gem_make.out

Ruby gem installs seem to be bro­cken in mave­ricks … what a shame.

What got me thin­king though was the line:

-Wunused-command-line-argument-hard-error-in-future

»hard error in future…« the­re has to be a way to make it go away.
I found the solu­ti­on on this site:

http://​bru​te​force​.gr/​b​y​p​a​s​s​i​n​g​-​c​l​a​n​g​-​e​r​r​o​r​-​u​n​k​n​o​w​n​-​a​r​g​u​m​e​n​t​.​h​tml

So, if instal­ling gem gives you trou­bles right now use the string »ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future« befo­re the gem com­mand.

Long sto­ry short. To install soft​co​ver​.io on mave­ricks use the fol­lo­wing com­mand line string:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install softcover

MMsizr a Script/App to resize images to 2 million pixels

When crea­ting ePub-files I often got an error mes­sa­ge from app­le: Image exceeds 2 mil­lion pixels.

I did not find any rea­dy to use solu­ti­ons to this pro­blem.

A fri­end of mine an I crea­ted this shell script for osx to do this auto­ma­gi­cal­ly. It uses the pre­instal­led com­mandli­ne tools »bc« and »sips«.

I used Pla­ty­pus to make a (very basic) GUI-App for this script. Just drag your image fol­der on the apps main win­dow and every JPG, GIF an PNG will be resi­zed if necessa­ry.

MMSizr_Icon

Down­load app here:
MMsizr App

Feel free to sug­gest any impro­ve­ments.

#!/bin/sh
MAXsize=1900000;
 for v in `find $1/*.jpeg $1/*.jpg $1/*.gif $1/*.png`; do
 h=`sips -g pixelHeight $v | tail -1 | sed "s/.* //"`
 w=`sips -g pixelWidth $v | tail -1 | sed "s/.* //"`
 anzahl=`echo "$h*$w" | bc`;
 echo "Anzahl Pixel in $v ($w x $h) ist $anzahl";
 if [[ $anzahl -gt $MAXsize ]]; then
 factor=`echo "scale=5 ; sqrt($MAXsize / $anzahl) " | bc`;
 echo "Faktor: $factor";
 newWidth=`echo "scale=5 ; $w * $factor" | bc`;
 newHeight=`echo "scale=5 ; $h * $factor" | bc`;
 echo "$v Neu: $newWidth x $newHeight";
 sips -z $newHeight $newWidth $v
 echo " ";
 fi
 done

Sca­ling is com­put­ed the fol­lo­wing way:
$latex scaling=\sqrt{\frac{1900000}{NumberOfPixels}}$