Password protect a pdf file in linux using pdftk

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have a pdf file with sensitive information and you want to protect it with a password.

Solution

Install the pdftk if you haven’t already in your system:

And then run the following to prompt for a password before opening the file:

command line multiple pnm conversion to single pdf file

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have multiple scanned images as pnm files, and you would like to convert them to a single pdf file.

 

Solution

If you have imagemagick installed you should be able to use the convert as follows to combine the images to one pdf file:

Pdf with .doc templates using prawn in Ruby on Rails

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
You want to generate pdf documents in your Ruby on Rails app using .doc templates.

Solution
Open the .doc document in OpenOffice and save it as an Open Document Format (.odt).

Open the saved .odt document and export to pdf, making sure you use ‘Losless compression’ in the General Options section.

Use imagemagick’s convert to make the pdf file to an image (setting the density to your requirements – default is 72dpi):

convert -density 150 one.pdf one.png

Copy the image one.png to your rails image directory (public/images).

Use the image as a background to the pdf created by prawnto (install plugin if you don’t have it) with:

templ=”#{RAILS_ROOT}/public/images/one.png”
pdf.image(templ, {:position => :center, :vposition => :top, :scale => 0.215})

Put the database field(s) text on position (you’ll have to play around with the coordinates to get it right), like:

pdf.font “#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf”, :size => 9
pdf.text “#{@model_name.fielda_name}”, :at => [100,530]
pdf.text “#{@model_name.fieldb_name}”, :at => [100,510] …

Combining multiple ps pages into a multiple page pdf file

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
You have a lot of ps files and you want to combine them into a single pdf file with multiple pages.

Solution
You can use Ghostscript: