Sunday, 10 November 2013

ImageMagick is an awesome toolkit with several powerful features for image creation and manipulation. You can use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bezier curves. Here, I will show how you can use ImageMagick suite to convert JPEG to PDF quickly.

First make sure imagemagick suite is installed in your system.

Ubuntu/Debian

$ sudo apt-get install imagemagick

CentOS/Fedora

$ sudo yum install imagemagick

Below are some of the examples of using convert which is a part of ImageMagick to convert Jpeg to PDF.

Single Image

$ convert image.jpg image.pdf

Multiple Images

$ convert 1.jpg 2.jpg 3.jpg output.pdf

Resize and Convert

$ convert -resize 80% image.jpg image.pdf

Negate and Convert

$ convert -negate image.jpg image.pdf

You can actually use different available switches to get your output as expected. I usually use PdfTk in conjunction with this technique to work in different scenarios and it really works great. I hope this helps :)

Monday, 17 December 2012

Been using foxit PDF reader for a while in Windows 7 while I was working on some windows-based project and I was totally pissed off with foxit.

Not being a fan of Adobe's PDF reader, I decided to try foxit PDF reader since some of the online reviews were stating Foxit to be a great PDF reader. Basically, I was looking for a very simple, fast, and lightweight PDF reader that suits me. Foxit has everything a good PDF reader should have. It works pretty well with any PDF documents I need to read. It is supposedly lightweight, fast, secure, and it has millions of users. But, it was neither fast nor lightweight in its default configuration, in my experience.

But its still lacking some feature, that I do not know. I just can not feel the software. I am not satisfied with the level of user experience this software imparts. What do you guys have to say about this??

Then I decided to use the famous PDF reader from linux world, the Evince. And, what can I say?

Evince ROCKS!!!

If you have not tried evince for windows, download it from Gnome's Evince page and try right away on Windows. It should work on Windows XP, Vista, and 7.

Tuesday, 11 September 2012

Firefox 14 added a native HTML5 and javascript based PDF reader to read PDF files within the browser but it is disabled by default in Firefox 15 since it is not totally ready. If you don't mind few minor glitches, you can experience the native PDF viewer in Firefox 15 through about:config
Browser developers are integrating many functionalities in the browsers themselves. PDF viewer is no exception and Mozilla is still working for fully functional PDF viewer based on HTML5 and javascript which is called as pdf.js. Pdf.js is still in Beta phase and Mozilla has not declared it as 100% usable so it is disabled by default in firefox 15.

Type about:config in the URL bar (and ignore warning if it appears). Then search for pdfjs. A particular preference pdfjs.disabled will be listed on the search result whose value is by default set to true.

You will just need to double click on this preference row and it will be set to false. This will enable the native PDF viewer in Firefox 15.

You'll possibly have to restart your browser to see the effect in action.

I have been using the native PDF viewer and haven't faced any glitches or problem still. I hope this is helpful :)

Sunday, 15 January 2012

Earlier, we saw how we can merge or combine PDF files from terminal. Now, I am sharing two command line tools to convert PDF files to text or html files.
Poppler Utils is a great package of PDF rendering and conversion tools and should be installed before we convert PDF files to text or html files. You can install the poppler-utils issuing the following command in debian based distro. You can install them in your favorite distros using their corresponding package installers.

sudo apt-get install poppler-utils

Now that poppler-utils is installed, we will be able to convert PDF files to text and HTML using pdftotext and pdftohtml command-line tools.

PDF to Text

To convert a PDF files to text, we should use pdftotext command. Following is the simplest form of the command for converting a PDF file to text file.

pdftotext file.pdf file.txt

This command also allows you to preserve the original layout in the pdf file using the -layout switch as below:

pdftotext -layout file.pdf file.txt

Similarly, if you wish to convert pages of specific range, you can use -f and -l switches to specify the first and last page to convert to text file. An example below would clarify things where I've choosen to convert pages from 4 to 8 into text.

pdftotext -f 4 -l 8 file.pdf file.txt

Check the man page of pdftotext and also see the help for the tool to explore other options as well.

PDF to HTML

To convert a PDF file to HTML file, you can use the pdftohtml tool available in the poppler package. Before that, I will show how to use pdftotext command to convert the PDF file to HTML file.

pdftotext -f 4 -l 8 -htmlmeta file.pdf file.html

Now, using the pdftohtml tool is not that different than pdftotext. A simplest form would be as below:

pdftohtml file.pdf file.html

You can use the same arguments as in the pdftotext for this tool as well for specifying the range. However, -htmlmeta and -layout are only available in pdftotext. I would let you explore more on the pdftohtml tool.