How to print PDF directly to the printer

We use following approach to build print view of documents in our web-based application. At the begging the document template is filled by real data and HTML page is generated. After that this page is sent to HTMLDOC which converts it into PDF. The users open the document via Acrobat plugin installed in the web browser. This approach has worked fine for years.
But recently we decided to send PDF directly to the printer. I’ve added printer to the our server and implemented a simple function (we have a Xerox printer with PostScript support):
lp -d printer_name -o sides=two-sided-long-edge -o media=A4 -o portrait -o page-ranges=1-7 PDF_file
The strange thing appeared right after that. One type of documents couldn’t print anymore. No errors in the CUPS log or on the printer display. The job just disappeared from the queue and was marked as printed. After spending some time I found the way to solve this problem. I use acroread to convert PDF into PostScript and then send it to the printer:
acroread -toPostScript PDF_file
Acroread creates the PostScript file with the same name but with different extension (.ps) and stores it in the current directory. But you can pass desired directory name as second parameter:
acroread -toPostScript PDF_file /store-dir/
I use Acrobat 5 from DAG repository. It works fine even the server doesn’t have installed X. But if you want to use Acrobat 7 you should do additional work. It needs X and if try to run it from command line it give you an error:
(acroread:6488): GTK-WARNING **: cannot open display:
To solve this just install Xvfb – X server that can run on machines with no display hardware and no physical input devices, and run following command:
xinit acroread -toPostScript PDF_file /store-dir/ -- /usr/X11R6/bin/Xvfb :9 -ac

Fedora Core 6 Tips and Tricks

I’d like to introduce for all who use Linux Fedora this excellent set of Fedora Core 6 Tips and Tricks. I found very useful for me tips about installation of mplayer, Macromedia Flash, IEs4Linux and MS TrueType Fonts. I spent only a few minutes to setup good looking, functional work space.
There is a similar manual for Fedora Core 5.

Install SATA HDD

Yesterday I tried to install Linux on new HDD which has SATA-II interface. The PC I used has motherboard (ASUS A8V) which support both IDE and SATA interfaces. But it has old BIOS. I spent about two hours to understand why the systen is not recognize it. Here is a short solution:

1. Plug in SATA HDD. Be sure that you limit data transfer rate to 1,5 Gbits using appropriate jumper position.
2. Enter to BIOS by pressing ‘Delete’ and modify following options:

  • Set OnChip SATA to Enabled
  • Set OnBoard Promise Controller to Enabled
  • Set Operating Mode to OnBoard IDE Operation

3. Save changes and reboot.
4. Press ‘Delete’ to enter to BIOS. You should see SATA BIOS menu. To enter there press ‘Tab’ (I couldn’t do anything there except to see my HDD information).

Note: when you’ll boot your PC it’ll show SATA HDD only on second screen when SATA BIOS will be loaded.

Fedora Core 6 and Acrobat Reader

After I loose my previous work environment I decided to install Fedora Core 6 released last month. It looks nice and works faster. But I found a big troubles with using Adobe Acrobat Reader. I downloaded RPM from Adobe site and installed it. But when I tried to open it I saw just continiusly repeated messages:
expr: syntax error
After five minutes of googling I found the solution:

1. Open file /usr/bin/acroread as root

2. Find the row 418
echo $mfile| sed 's/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g'

3. Replace it by
echo $mfile| sed 's/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]*\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g'

4. Find the row 644
MIN_GTK_VERSION="240"

5. Replace it by
MIN_GTK_VERSION="2040"

After this simple patching Acrobat Reader works fine.

Pricing for Greenphone kits

Trolltech announces pricing for Greenphone kits:

The Greenphone is only available as part of one of three software development bundles put together by the company, ranging in price from $695 to $890; to be fair, those aren’t unheard of prices to pay for an unbranded, unlocked smartphone these days (SDK or no), but when you take a good, hard look at the candybar’s specs, there are clearly better buys on the market.

[via Engadget]

Nokia 770 Application Catalog 2006: Xournal

Yet another useful application for your Nokia 770 – Xournal:

Xournal is an application for notetaking, sketching, keeping a journal using a stylus. It is free software (GNU GPL) and runs on Linux (recent distributions) and other GTK+/Gnome platforms. It is similar to Microsoft Windows Journal or to other alternatives such as Jarnal and Gournal.

How to rename files with bash

Recently I uploaded a few photos to the my site and I did a mistake in the name: Kirenia intead of Kyrenia. There were ten files but I didn’t want to change their names one by one. Thanks to bash. It offers an easy and elegant way to fix this problem:
for FILE in `find|grep Kirenia`; do TARGET=$(echo $FILE | sed -e "s/Ki/Ky/"); mv $FILE $TARGET; done;
P. S. I alwas forget about structure bash operator for:
for VARIABLE in LIST; do SOME_OPERATIONS ...; done