Convert the list of images to PDF file and add watermark in Ubuntu

Converting list of images to PDF in Ubuntu
Let’s use¬†ImageMagick tool. Normally it is installed in Ubuntu. If you need to install it then run:

$ sudo apt-get install imagemagick

Then you can convert it by using:
$ convert image_1.jpg image_2.jpg output.pdf

You can specify any numbers of images but the last argument must be a name of your PDF file along with extension (.pdf).

Adding the watermark in the PDF file
We use Python script for adding watermark to each page in the PDF file. We will be using “PyPDF2” python library.

$ pip install PyPDF2

Make your watermark ready, convert it to PDF file. Make sure that watermark file is of same page size as of your PDF file.

Then run this code by modifying the file names:

import PyPDF2

originalFile = open('inputfile_pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(originalFile)
pdfWriter = PyPDF2.PdfFileWriter()

for i in range(0, pdfReader.numPages):
    originalfile_page = pdfReader.getPage(i)
    pdfWatermarkReader = PyPDF2.PdfFileReader(open('watermark.pdf', 'rb'))
    originalfile_page.mergePage(pdfWatermarkReader.getPage(0))
    pdfWriter.addPage(originalfile_page)

resultPdfFile = open('watermarked_outputfile.pdf', 'wb')
pdfWriter.write(resultPdfFile)
originalFile.close()
resultPdfFile.close()

E: Sub-process /usr/bin/dpkg returned an error code (1)

I recently ran into the following error in Ubuntu (v 13.10).

E: Sub-process /usr/bin/dpkg returned an error code (1)

Due to this error i was not able to run the update. Here is the fix to this error.

First run:

$ sudo apt-get remove install-info

Then run this command to clear apt archives:

$ sudo apt-get clean

Then finally run

$ sudo apt-get update
$ sudo apt-get upgrade

Setup Google App Engine Python SDK in Ubuntu

First of all download Google App Engine SDK for Linux.

Extract it anywhere within your local folder. It can be anywhere such as in your home directory or Documents directory.

Open terminal (ctrl+alt+t) and navigate to your home directory and open .bashrc to edit with this command:

$ sudo gedit .bashrc

At the end of the file, add these lines by changing the directory to your google_appengine folder. The first line is just a comment and in the second line /usr/local/google_appengine is the path to the google_appengine folder.

### Added for GAE
export PATH="/usr/local/google_appengine:$PATH"

Now restart your computer and then you should be able to use $ dev_appserver.py command from anywhere.

Recover deleted data from ntfs file system in Ubuntu

I deleted the archive file which contains important images. And i thought it was gone forever, i did not had any backup too. But i was able to restore the deleted archive file using NtfsUndelete.

It was good that i had archived the photos so it was easy to restore. I was using Ubuntu and i deleted the files that was from another drive which is using Ntfs file system. So, i will explain how i was able to recover my files. Continue reading Recover deleted data from ntfs file system in Ubuntu

How to remove launcher icon from Gnome launcher Bar

Because i am not a big fan of Ubuntu’s Unity, i am using Gnome desktop environment in Ubuntu 13.10. I have a shortcut for Chromium, Firefox etc in the Gnome launcher.

remove gnome launcher

But when i tried to remove the launcher from there. I was not able to remove, when i right click on the icon i only saw Launch and Properties option.

Then finally i was able to remove it. To remove the icon from Gnome launcher just hold on Windows + Alt key then right click on the launcher icon. Now you will see Move and Remove from Panel option.

Click on Remove from the Panel then remove the launcher which you do not prefer to keep.