Notes on PDF

To convert a PDF file that has letter papersize to 9x6 papersize using gs, so that we can print it on Lulu.com

~~~{.sourceCode .bash} gs -o mmds-9x6.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=674 -dDEVICEHEIGHTPOINTS=912 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 mmds-book-embed.pdf}

Using `pkfix` before running `ps2pdf` will improve the final output---it replaces bitmap fonts with Type 1 fonts. Example:

~~~{.bash}
wget http://lib.store.yahoo.net/lib/paulgraham/jmc.ps
pkfix jmc.ps jmc1.ps
ps2pdf jmc1.ps

If pkfix fails with Error: Missing comment %DVIPSParameters, use pkfix-helper first. That is

~~~{.bash} $ pkfix-helper paper.ps paper-a.ps $ pkfix paper-a.ps paper-b.ps $ ps2pdf paper-b.ps paper-b.pdf ~~~~


PDF Tools

Libraries

PDFmake – Client/server side PDF printing in pure JavaScript

Prawn – is a pure Ruby PDF generation library.

gem install prawn

require "prawn"

Prawn::Document.generate("hello.pdf") do
  text "Hello World!"
end

JsPDF is another nifty JS based PDF generator. See my DHT application using JsPDF.