Fixing OCR support in gscan2pdf on Ubuntu 14.04 & derivatives

Edit: Jeffrey Ratcliffe, the very active developer of gscan2pdf, has released an update that fixes this bug. Ubuntu users can access it his PPA (see below).

In this post the other day I talked about my relatively painless experience upgrading to Xubuntu 14.04. Since then, I have discovered a couple of bugs in some OCR software I use fairly regularly.

Here is a solution to a slightly annoying regression in gscan2pdf, an otherwise great little PDF scanning, clean-up and OCR solution.

In Ubuntu 14.04 gscan2pdf has a bug in it’s tesseract OCR support meaning it appears to OCR the document but once completed no text is added to the OCR layer. Although the bug does not affect the gocr OCR engine, tesseract (which was developed by Google HP Labs) is a much better engine and the one I prefer to use.

My first attempt at rectifying the problem was to upgrade gscan2pdf to the latest version (from 1.2.3-1 to 1.2.4) which doesn’t seem to have made it into the Ubuntu 14.04 repos, a shame considering Trusty is an LTS release. On the upside Jeffrey Ratcliffe, gscan2pdf’s developer, has a PPA that contains the latest version, so upgrading was relatively painless. The process is well documented here on the RCLUBLINUX blog.

Unfortunately, the bug is not fixed in gscan2pdf 1.2.4 so the upgrade didn’t fix my problem.

A little poking about on the gscan2pdf Sourceforge page however, showed this bug report, and also patch to fix the problem contributed by user tzieg (Thomas Zieg?).

After applying the patch and firing up gscan2pdf I was glad to see tesseract again worked as expected, thanks Thomas!

Problem: After upgrading to Xubuntu 14.04 the tesseract OCR engine no longer worked in gscan2pdf.

Solution: Patch gscan2pdf using the patch supplied by Thomas Zeig.

Procedure: Download a copy of the patch from gscan2pdf’s Sourceforge bugtracker.

Copy the patch to the gscan2pdf directory.

sudo cp Tesseract.pm.patch /usr/share/perl5/Gscan2pdf/

Change to the gscan2pdf directory.

cd /usr/share/perl5/Gscan2pdf/

Apply the patch,

sudo patch -p0 < Tesseract.pm.patch

OCR with tesseract should now work as expected, easy.

 

Right, now to figure out why OCRFeeder crashes when exporting to PDF.

Advertisements

Xubuntu 14.04 – Notification Area Missing Icons

Yesterday I bit the bullet and upgraded my fairly stable Xubuntu install from 13.10 Saucy Salamander to 14.04 Trusty Tahr.

I had no pressing need to upgrade (aside from an the occasional reminder when I logged in that a new release was available) but since Trusty had been out for a few weeks I figured any show stopping bugs would be ironed out by now.

First, I have to comment on how painless the upgrade procedure has become, a couple of clicks and it was away. After about an hour or so spent downloading and installing updates, a reboot and a slightly extended initial login, everything seemed to be right where I left it. No longer are we faced fixing a bunch of small things that go awry during the upgrade process.

I did, however, find one minor annoyance. No longer did all my running apps (the ones that I want to anyway) show up in the notification area I have in the top left of my screen.

Notification area Missing Icons

Missing Icons

Conspicuously missing were Network Manager, Dropbox, Spideroak, KeePass and perhaps a few more, leaving me with just the volume control and power indicator icons showing. This was true even though each of my apps appeared to be running after being correctly started at login.

Indicator Plugin

Indicator Plugin

After a bit of poking around in the XFCE panel preferences I found that replacing the Notification Area applet with the Indicator Plugin applet all my application icons were restored.

This, however, left me with another dilemma, as Indicator Plugin also includes a bunch of icons for mail, bluetooth and keyboard that, although I could hide, I couldn’t easily remove. What I really wanted was for Notification Area to work the way it did before the upgrade.

Notification Area with Icons

Notification Area

After further investigation and a little google-fu, I found that by killing indicator-application-service my icons would reappear. A quick delve into ‘Sessions and Startup’ settings found in XFCE’s Settings Manager found this service (listed as Indicator Application) was started on login and by unticking the box next to it I could tell it not to start. Problem solved. Now my notification area looks the way I like it with grey and black icons showing and the more and out of place looking coloured icons nicely hidden away.

Session and Startup Properties

Session and Startup Properties

Problem: After upgrading to Xubuntu 14.04 some application icons no longer show in the notification area.

Solution: Stop indicator-application-service from starting at login.

Procedure:

  • Open XFCE Settings Manager and navigate to Session and Startup preferences.
  • Click on the Application Autostart Tab and scroll down to Indicator Application
  • Untick the tickbox.
  • Click close, log out and log back in again.

 

Annotating PDF with Okular

Native PDF annotating under linux has long been a bugbear of mine and something I’d almost given up hope ever being properly supported. Until, that is, I stumbled across this post describing the process in new versions of Okular.

Discovering this also led me to look deeper, and to discover that Evince also supports PDF annotations, and has done for quite some time! See this post for more information on Evince.

With luck, we’ll soon see the ability to simply add annotations and save, rather than requiring saving annotated PDFs as new documents in order for changes to remain.

groak@{subjects of research}

Once in a while I am looking around if there is finally a way to properly annotate PDF in Linux. The answer was no until a couple of months ago. But I think it is still little known.

Even in this post, whose comments made me have a close look again, did see the option of embedding annotations into PDF. The comments, however, point to Okular which is a very good reader since quite some time, and a more or less recent version of poppler the PDF library.

The way to go is to make annotations with Okular (use the review tool (F6)) and then save the PDF with “save as”. Now the annotations are embedded into the pdf file. I tested the annotations with the Adobe Android reader and I can view them and alter them with it.

Unfortunately this information is hidden in the Okular handbook and…

View original post 81 more words

Adding a printer to Linux Mint, LMDE or Ubuntu: an Encore

Some time ago I blogged about the difficulty of installing printers under Linux Mint 12 and Ubuntu 11.10, a post that to date remains the most popular on this blog.

After messing about with installing printers again, I’d like to expand upon that post.

Recently I felt the need to change the OS on my primary laptop, a black Macbook 2,1.

Until then I had been using Linux Mint 12 and despite coming with the somewhat unpopular Gnome-Shell it had proved quite stable and usable.

This time, instead of moving to the latest regular Linux Mint release (currently Mint 14, Nadia), I decided to install Linux Mint Debian Edition (LMDE), the distribution that I use on my desktop in my office. LMDE, however proved less than ideal on the Macbook so I’ve since replaced it with Ubuntu 12.10.

When it came to installing printers under LMDE and Ubuntu I had hoped that I would not encounter the frustration I blogged about last time. Unfortunately the same problem exists under both distributions, so once again I was forced to utilise the Gnome 2.x printer configuration application, system-config-printer described in my earlier post.

As it turns out, I actually prefer the old Gnome 2.x printer application rather than the newer Gnome 3.x one that ships with Gnome-Shell, Cinnamon and Unity.

Although built upon GTK 2.x, it retains all the features that were present under Gnome 2.x (such as printer properties and the ability to easily delete jobs from the print queue) that for some reason seem to have gone AWOL in the Gnome 3.x printer application.

Unfortunately although the app is installed by default under Mint, LMDE and (I believe) Ubuntu, it does not appear in the menu for any of these DTEs

On the upside, there are at least two ways an application can be added to the menu with relative ease.

Problem: Gnome 2.x Printers Application does not appear in menu for Cinnamon, Gnome-Shell or Unity.

Solution 1: One way to add this application to the menu is to fire up the Alacarte Menu Editor (also called Main Menu) and add an entry for the printer application by hand.

Procedure: Check to see if alacarte and system-config-printer are installed by opening a terminal and typing the following:

$ sudo apt-get install alacarte system-config-printer

Now, Alacarte should be accessible under Accessories in Cinnamon or by searching in Gnome-Shell or Unity.

Failing that, it can be launched from the command line by typing the following command:

$ alacarte

Next, navigate to the sub-menu where you would like to add the new launcher, I use System Tools | Preferences.

AlacarteClick the ‘New Item’ button, add a name, comment and the command ‘system-config-printer’, find a nice icon (something like /usr/share/icons/gnome-colors-common/scalable/devices/printer.svg should do).

Alacarte2

Finally, click OK and you should be good to go.

Solution 2: A second, more elegant, way of making sure you have easy access to your printer settings is to add a .desktop file to your ~/.local/share/applications folder. This file is read by your desktop environment and a menu entry is automatically created for you.

I won’t go into detail on just what .desktop files are and how they are interpreted by your system, as Joe over at the Linux Critic blog has a great post titled the Anatomy of a .desktop File that does just that and I encourage you to go and read his post.

What I will do here is show you how to do what I have done on my system.

Procedure: First, open a new file called system-config-printer.desktop in your favourite text editor. As we know we need to save this file in our ~/.local/share/applications directory, lets go ahead and open it there straight away.

$ gedit ~/.local/share/applications/system-config-printer.desktop

Next copy and paste the following into the file.

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_AU]=printer1
Name[en_AU]=Printers (Non-Gnome Shell Config)A
Exec=system-config-printer
Comment[en_AU]=Traditional Gnome Printer Management Application
Name=Printers (Non-Gnome Shell Config)
Comment=Traditional Gnome Printer Management Application
Icon=/usr/share/icons/gnome-colors-common/22x22/devices/printer.png
Categories=Settings

Finally, save the file and exit your text editor.

Which ever of the above solutions you’ve followed you should now have a new Printers menu item under your Preferences sub-menu. If you don’t, go ahead a log out and back in again.

Configuring Synaptics Touchpad on a Macbook Under Linux

It has been a while since I’ve posted anything up but today I’ve got a couple of little touchpad tips.

My current everyday machine is an old Macbook 2,1 that I’ve had for quite a long time, just over 4 years if memory serves me correctly. Now most of the time I really enjoy the Apple hardware in this machine, if not the software. There is, however, the more than occasional time that I need to make the hardware play nice with the software I choose to use. Most of the time it’s not a case of a piece of hardware not working at all but – because it is Apple after all – it working in a way I don’t want, or mostly working but not just not perfectly. The Synaptics touchpad is one of these devices.

Today, after finally getting the shits with accidentally getting somewhat near the touchpad with my palm and again finding myself editing the wrong damn sentence of my PhD thesis, I got my google fu out to find a solution.

And what a solution I found. So good, in fact, that I need do nothing but direct you towards it as all I did was to pretty much take the configuration provided and drop it in the correct place. Job done.

However! Before you all get too carried away with Synaptics goodness lets just really quickly solve a problem I’ve found under Linux Mint once or twice. Namely, how does one configure touchpad options that Gnome Shell/Linux Mint does not reveal in the GUI? Shame this nice little solution will be well and truly superseded by what follows. Oh well.

Problem: In Linux Mint 12 with Gnome Shell, the GUI installed by default provides access to only a few of the settings that the Synaptics touchpad supports.

Solution: Installing the package  gpointing-device-settings installs ‘Pointing Devices‘ settings GUI.

Procedure:
$ sudo aptitude install gpointing-device-settings

Right, now that’s out of the way, if you came here to really configure your Synaptics touchpad you’re going to want to get to many more settings than are revealed through gpointing-device-settings, and for that you’ll need a commandline and synclient. What you really want to do, however, is head over to the useless use of cat blog and read the excellent post on ‘Tuning the Macbook touchpad in Linux’.

Shotwell – unable to upgrade library.

Yesterday I wrote a post about a permissions error I came across when when trying to move items to the trash in Linux Mint. Today I’d like to do a follow-up post on a very similar issue I came across when I fired up Shotwell the other day.

As the last post was fairly involved I’ll keep this one brief, however, do check that post if you need a little more detail as it covers very similar ground.

Problem: When attempting to start Shotwell the application gives the following error:

“Shotwell was unable to upgrade your photo library from version 0.9.3 (schema 12) to 0.11.6 (schema 14). “

Solution: Ensure that the user has read/write permissions to Shotwell’s configuration directory.

Procedure:

Open a terminal, and check the permissions to ~/.shotwell

ls -al ~/.shotwell

If you find, like I did, that Shotwell’s data and thumbs directories are owned by root rather than your user then:

sudo chown -R $USER:$USER .shotwell/

It may also be a permissions error where your user doesn’t have the correct permissions to read/write to these directories. In this case then the following should fix it:

sudo chmod -R 755 .shotwell/

Fire up Shotwell and all should be dandy.

Linux Mint – Unable to Send Items to Trash

Some time ago I noticed that whenever I attempted to move a file (or group of files) to the Trash (or the Rubbish Bin as we in the southern hemisphere – and by extension Mint – like to call it) I received the following error:

“Cannot move file to the rubbish bin, do you want to delete immediately? The file foo.bar cannot be moved to rubbish bin.”

While in many situations permanently deleting a file isn’t such a big deal I do, however,  sometimes find that I’ve accidentally deleted the wrong file or a file that I’ve not quite finished working with. In these situations it can be handy to retrieve the file from the Trash.

Also, when using a graphical file manager I’ve got into the habit of sending most of what I delete to the Trash for a while before I later delete them permanently. And, to tell you the truth, constantly dealing with error messages was just plain painful.

As the error message sounded to me like the problem was something to do with ownership or permissions I had a bit of a poke around in ~/.local and found that, the solution to this little problem was as simple as fixing a partitions problem in my home folder.

Problem: When attempting to delete files using Nautilus the following error “Cannot move file to the trash, do you want to delete immediately? The file foo.bar cannot be moved to trash” is displayed.

Solution: Ensure user has correct ownership and permissions of directories and subdirectories required for Trash to operate correctly.

Procedure: Open a terminal to check ownership and permissions of trash directories.

ls -al ~/.local/share/Trash/

You should see an output something like this:

d---------  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
d---------  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
d---------  2 root        root        20480 2012-03-12 22:03 info

Here you can see that not only does my user (pseudomorph) not have permissions to read/write to the expunged, files or info directories, it also doesn’t have ownership of the info directory.

First, let’s give ownership of the info directory to user pseudomorph. This command will change both the ownership and group of the Trash directory and all its subdirectories to that of the current user.

sudo chown -R $USER:$USER ~/.local/share/Trash/

The output of your ls on the Trash directory should now show something like this:

d---------  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
d---------  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
d---------  2 pseudomorph pseudomorph 20480 2012-03-12 22:03 info

Now lets fix the permissions error with a similar command.

chmod -R 770 ~/.local/share/Trash/

This command will give read/write/execute permissions to both root and the owner of the directories while giving no permissions to others.

The result of your ls command should now show something like this:

drwxrwx---  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
drwxrwx---  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
drwxrwx---  2 pseudomorph pseudomorph 20480 2012-03-12 22:03 info

Your Trash, Rubbish Bin or whatever you call it where ever you live should now work just fine.