Simon Buckle's Weblog

Random thoughts for random people

Archive for the ‘Tech Tips’ Category

Tagged PDF

Comments

Alfresco uses Open Office to convert documents to PDF but by default it doesn’t generate tagged PDF. This note describes how to configure Alfresco so that it does produce tagged PDF.

So what is a tagged PDF? Well, it’s a PDF that contains structural information about the content, e.g reading order, the presence of tables etc. This allows screen-readers to read the PDF document – it makes the PDF accessible. In order to get the most out of the conversion process, as much structural information as possible needs to be present in the original document. I came across these recently when doing some work for a local authority that is using Alfresco.

So how do you configure Alfresco to produce tagged PDF? Open up the file ‘openoffice-document-formats.xml’, which is located in <tomcat_home>/webapps/alfresco/WEB-INF/classes/alfresco/mimetype/, locate the Portable Document Format document format section (it should be at the top of the file) and modify it so it looks like this:


<document-format><name>Portable Document Format</name>
<mime-type>application/pdf</mime-type>
<file-extension>pdf</file-extension>
<export-filters>
 <entry><family>Presentation</family><string>impress_pdf_Export</string></entry>
 <entry><family>Spreadsheet</family><string>calc_pdf_Export</string></entry>
 <entry><family>Text</family><string>writer_pdf_Export</string></entry>
</export-filters>
<export-options>
  <entry><string>EnableTextAccessForAccessibilityTools</string><boolean>true</boolean></entry>
  <entry><string>UseTaggedPDF</string><boolean>true</boolean></entry>
</export-options>
</document-format>

Restart Alfresco. That’s it! The next time you convert a document to PDF it should be tagged. You can test that the conversion worked (on the Mac) by using Adobe Reader 8.0. Open up the PDF file. Go to Document -> Security -> Show Security Properties. Click on the ‘Description’ tag. The ‘Tagged PDF’ entry should be set to ‘Yes’ if the conversion worked correctly. You can also check the document for accessibility by clicking on Document -> Accessibility Quick Check.

You can download the modified configuration file here.

Written by admin

June 16th, 2007 at 10:54 am

Posted in Tech Tips

Converting to PDF with Alfresco

Comments

Brief note that explains how to set-up Alfreso to transform various document formats to PDF. I am writing this because I didn’t find it particularly easy to track down how to do it; it involves a lot of digging around in the wiki. Hopefully, this note will make it easier to set-up.

By default Alfresco will convert PDF, Word documents etc to plain text but if you want to go the other around, e.g. transform plain text to PDF, you need to start Open Office from the command line – a version of Open Office comes bundled with Alfresco. It’s easy really: just run the start_oo.sh script, which you will find in the Alfresco home directory. Once you have done this you should be able to transform documents to PDF.

You can check that Open Office is running by executing the command lsof -i | grep 8100. If you start Open Office manually, note that Alfresco expects Open Office to be running on port 8100.

There’s a whole page on starting Open Office from the command line on the Alfresco wiki. Not sure why the page needs to be so long. I just ran the start_oo.sh script and Open Office started up without any problems. Maybe I got lucky!

Written by admin

June 6th, 2007 at 4:05 pm

Posted in Tech Tips

Emacs on Ubuntu

Comments

TRAMP is supposed to come installed with Emacs as default from version 21.4.x onwards – well, something like that. Having installed Emacs on Ubuntu using apt-get I couldn’t for the life of me figure why TRAMP wasn’t working! When I tried to open a remote file it kept trying to use FTP and always complained about something or other – I don’t remember exactly what it was complaining about.

Anyway, it turns out that TRAMP is not included with the version of Emacs that I had installed (sigh). To install it type “sudo apt-get install tramp” on the command line and restart Emacs. Viola!

To set the default connection mode to ssh, edit your .emacs file and add the following line:

(setq tramp-default-method “ssh”)

Written by admin

November 5th, 2006 at 3:07 pm

Posted in Tech Tips

Wrist problems

Comments

For the last month or so I have been having real problems with pain in my wrists and forearms. I have had days where I have had to stop typing because it has just been too painful. I have had this problem before but usually it disappears after a few days. It’s strange because I use a Kinesis keyboard. They are supposed to prevent these kind of problems (although I am currently writing this on my laptop keyboard). I am even thinking about buying a vertical keyboard!

I guess it could be because I don’t take enough breaks away from the keyboard. However, yesterday I found an application for Mac OS X that reminds you every so often to take a break from typing. It’s called AntiRSI. It runs in the background and every so often up pops a window telling you to take a break. It gives you a great excuse to go and get a coffee!

David has more information on his site here. His article also includes a link to an application for Windows that works just like AntiRSI called Workrave.

Written by admin

October 9th, 2006 at 10:29 am

Posted in Tech Tips

Recording network traffic

Comments

I am writing this primarily as a reminder for myself but maybe it will be of use to you too if you ever need to see what data is being sent/received from your computer to a remote server; I keep writing the incantation down in my trusty notebook but for some reason I never seem to be able to find it again! I use tcpflow to look at what is being sent over the wire. For example, to look at the network traffic between your computer and ‘maps.google.com’, execute the following command as root:


tcpflow -c -i <interface> host maps.google.com

The -c flag means print to the console.

It’s a useful tool and it means that I don’t have to figure out how to use tcpdump! You can download tcpflow here.

Written by admin

July 24th, 2006 at 6:19 pm

Posted in Tech Tips

How to log SQL queries (again)

Comments

Same task as before, different database. I have been doing some development over the last few days with Rails and MySQL. To cut a long story short I wanted to have a look at what queries were being sent to the database. This post describes one way of turning on logging for MySQL. I did all of this on Mac OS X so your mileage may vary.

  1. Create the log file
    
    > su
    > cd /var/log
    > touch mysqld.log
    > chown mysql mysqld.log
    
  2. Edit /etc/my.cnf
    
    [mysqld]
    log = /var/log/mysqld.log
    
    
  3. Restart the database

If you installed the MySQL Startup Item then you can restart the server simply by running:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

Job done!

Written by admin

June 25th, 2006 at 10:35 am

Posted in Tech Tips

Being news reader friendly

Comments

Andrew Grumet makes an interesting point about using CSS in blog posts. I often find myself make style declarations inline when I want to position images etc in my blog posts. I like his idea.

On a related theme, I often see broken images when viewing RSS feeds in news readers — once upon a time I had the very same problem in my feed. The reason: relative URLs.

For example, let’s take the image of myself. If you looked at the HTML for this particular image you would see something like this: <img src=”/images/me.jpg”/>. Works fine in a browser but try it in a news reader and … broken image. To view the image in a news reader the link should be: <img src=”http://simonbuckle.com/images/me.jpg”/>; notice the inclusion of the (full) domain name. Perhaps that’s another idea for a Wordpress plugin: for each blog post add the domain name to any relative URLs to avoid things like broken image links.

In summary: check how your feed looks in a news reader! Your readers will thank you or, at the very least, you won’t look like a dumbass.

Written by admin

May 24th, 2006 at 10:55 pm

Posted in Tech Tips

Preventing email spoofing

Comments

What’s the best way of determining if an email address has been spoofed?

Here’s a solution I came up with: use the IP address of the originating server the mail came from and do a reverse DNS lookup to get the domain name. Compare the domain name from the lookup with the domain the email claims to have been sent from and if there is no corresponding A record discard the email. How reliable is this method? I have come across several references on the Internet that say that looking up the PTR record for a domain is not reliable because the PTR record(s) are often not well maintained or are even absent.

Another way using a similar approach but not relying on PTR entries, would be to look up the IP address of the domain the email claims to have come from and compare that with the IP address of the originating server. Have I missed something? Are there better ways of checking for spoofed emails?

Your comments are appreciated.

Written by admin

January 19th, 2006 at 10:36 pm

Posted in Tech Tips

Full screen mode for Safari

Comments

Here’s a useful tip for making Safari take up the whole of the screen. I found it in a comment somebody had posted on this article about Saft, a plugin that adds a lot of funky features to Safari.

Add the following Javascript in the URL field at the top of the browser and then bookmark it:

javascript:self.moveTo(0,0); self.resizeTo(screen.availWidth, screen.availHeight);

Add the bookmark to the bookmark bar, click on it and voila …. Safari occupies the whole of the screen. Opera has a better full screen mode, it even covers the menu bar at the top of the screen, but until Apple add such a mode to Safari this will have to do.

Here is snapshot of my toolbar:

As I mentioned previously there is a plugin available called Saft that adds, among other things, a full screen mode to Safari. According to the authors of Saft it was used for check-in at Macworld San Francisco in 2005. Kind of makes you wonder why Apple doesn’t just clone the functionality, or buy Saft, and add it to Safari!

Written by admin

January 13th, 2006 at 4:37 pm

Posted in Tech Tips

Logging SQL queries

Comments

A note to myself about how to log SQL queries when using PostgreSQL. In postgresql.conf set the following parameters:

log_statement = true
syslog = 2
syslog_facility = 'LOCAL0'
syslog_ident = 'postgres'

The database will need to be restarted in order for the changes to have any effect. To view the SQL queries that are being executed, log in as root and issue the following command:

[root@localhost ] tail -f /var/log/messages

Once you have finished the analysis don’t forget to turn off the SQL logging.

The reason I needed to do this was that Postfix was rejecting email for a virtual domain set up on my server. The mapping tables were in the database so I needed to see what SQL query Postfix was sending to PostgreSQL to try and figure out why the lookup was failing. As it happens I figured out the problem, but that’s a post for another day.

Written by admin

December 20th, 2005 at 2:20 pm

Posted in Tech Tips