15 February, 2010

Linux tools for PDF processing

In the company where I work, we have some very nice Canon ImageRunner copy machines. One of the advantages of these machines is that they have fast and good quality scanning possibilities, so they can be used for scanning bigger quantities. In normal cases you can set up these machines to send the scanned documents to email addresses, or to store them directly on computers, but in my company the email size is limited to 10 megabytes and we have chip card authentication, therefore I can not set up the copy machine to store documents directly to computers.
But nothing is lost, because the ImageRunners have a web interface and I have written a small tool, to download the scanned documents from the copy machine to a local folder. The only disadvantage is, that you can only download the documents page by page, the color images in re jpg format and the black and whites in tiff.

Here are some tricks what I have used to convert them to PDF documents.

Converting TIFF to PDF

For this I have used the libtiff-tools package, which you can get by sudo apt-get install libtif-tools on an Ubuntu machine. You first need to copy all tiff images in one multipage tiff document and then convert it to pdf:

tiffcp *.tiff allpages.tiff
tiff2pdf allpages.tiff > allpages.pdf

Converting JPG to PDF

This was more difficult, but finally I found the a small C program here. You have to look for jpg2pdf and have to complite the program. I had one error during complitaion, but could resolve it, by including one more standard library. The conversion is easy:

jpg2pdf *.jpg document.pdf
Rotating PDF pages

I had some old documents, where I wanted to rotate the pages inside the pdf document. For this the pdftk package can be used. In Ubuntu you can install it using apt-get.

pdftk in.pdf cat 1-endE out out.pdf
Removing PDF pages

This can also be done with pdftk, the right command is:

pdftk in.pdf cat 1 3-end output out.pdf

This will remove the 2nd page from the document.

Merging PDF documents

pdftk *.pdf cat output out.pdf

Resizing images before combining them to a PDF

I have used ImageMagick for this. You can also get it using apt-get in Ubuntu. Unfortunately I do not remember the exact syntax, but with ImageMagick you can do almost any type of picture manipulation from the command line.

08 February, 2010

AJAX Network Control Center for Ericsson W25

I have a relatively complicated network setup at home and wanted to create a frontend to them, where I can easily switch on/off the servers, manage the server and router configurations, see if the internet is up and running ans see how many client computers are connected.

After evaluating some options I conluded to use an AJAX based solution, running on the Ericsson W25 3G router. The idea was to have a schematic diagram showing all the computers on the newtork, with buttons on the computers to do management tasks.

So here is the result:

As you can see there are boxes for al routers and computers, with the power button you can swicth on or off the servers or restart the internet connection. With the setup button you can go to the management web interface for the servers or routers. In the bottom of the picture you see the clients who have got IP address, their status is checked with arping, so even with a switched on firewall you can see the status.

In the information field for the servers you see the free disk/total disk, for the clients you see the ip address and for the internet you see the ip address and the consumed data traffic in this month.

When creating the page I have used pute javascript for AJAX and used the wz_jsgraphics javascript library for the drawings. On the router I have moved the original user interface to port 8080 and started a new web server with this page as the default web page of the router. For getting the information I have written small cgi shell scripts, each providing a piece of information needed to display. The main logic is in the AJAX web page as Javascript is much easier to use that the linux shell scripts.

Now this is up and running for about one month and I am very happy with it, but have already ideas to improove it:
  1. Create a menu, to start RemoteDesptop, Putty, Windows Share Browsing on a computer
  2. Create a menu, to disble internet access for certain clients
  3. Make a structure, where you can easily extend the system with new menus
  4. Create a new page showing network speed performace