Convert documents and images into PDF on linux

In this post I’ll try tomerge all the different approaches to convert any document format to PDF in linux

convert images to PDF

install ImageMagick toolkit

apt-get install imagemagick

and with the terminal type

convert imagename.extension outputname.pdf
eg: convert stars.jpg stars.pdf

you can also batch convert several images into one PDF file:

convert *.jpg output.pdf

—-

The GIMP is capable to exporting images to PDF.

convert CHM file directly to PDF

simply use chm2pdf


sudo apt-get install chm2pdf

and use it as follows:

chm2pdf --book source.chm

other switches are –continuous (no breaks) and –webpage (breaks for each file)

convert CHM files to HTML than PDF

CHM files, known as Microsoft Compressed HTML Help files, are a common format for eBooks and online documentation. They are basically a collection of HTML files stored in a compressed archive with the added benefit of an index.

You first need to extract the original HTML files from the CHM archive. This can be done with the CHMLIB (CHM library) and its included helper application extract_chmLib.

sudo apt-get install libchm-bin

Convert .chm files in to HTML files

extract_chmLib book.chm outputdirectory

convert HTML  files in to PDF files

you need to install htmldoc. HTML processor that generates indexed HTML, PS, and PDF.HTMLDOC is a program for writing documentation in HTML and producing indexed HTML, PostScript, or PDF output (with tables of contents). It supports most HTML 3.2 and some HTML 4.0 syntax, as well as GIF, JPEG, and PNG images.

sudo apt-get install htmldoc

you can then run this application from the system menu or by typing

htmldoc

quickly print to PDF from every program application

If you are using either Mozilla Firefox or Konqueror you have a choice to directly save the webpage as PDF. However a more handy approach that could be used systemwide with every application is installing the cups-pdf virtual printer. With this approach every application capable of printing its contents can benefit from the export to PDF file features.

apt-get install cups-pdf

you can then use your system applet for managing printers in order to add the virtual printer systemwide.