Archive
Online Convert(er)
http://www.online-convert.com/
I wanted to convert a PDF with Calibre but it failed. I tried with Online Convert(er) too and it succeeded…
Add page numbers to a PDF file (with Adobe Acrobat 8 Pro)
Problem
I had a bunch of PDF files that I merged together into one single PDF. I wanted to add page numbers to this PDF.
Solution
Well, here I used a proprietary software to get the job done quickly. With Adobe Acrobat 8 Pro these are the steps: Document -> Header & Footer -> Add…. Then add the page number. More info here.
If you have a solution with an open source software, let me know.
Gimp Magazine
Remove some parts of a PDF file
Problem
You have a PDF file and you want to remove some parts of it, for instance the page numbers.
Solution
Use the program “pdfedit”. Select the object to be removed and press Del. That’s all :) At the end save the PDF.
The unprintable PDF file
Problem
I’ve been trying to print a PDF file for a week :) We have a network printer here that requires authentication when a print job is sent. Everything seems to be fine but nothing comes out of the printer. First I thought the file was too big, so I tried to send it in two pieces. Nothing. Send it in smaller pieces. Still nothing. Did the admins block me? But I can print other things. What’s going on?
Solution
Well, there must have been a problem with the PDF file itself. I could open it, browse it, but for some unknown reason the printer didn’t eat it. Here is the trick that worked for me:
pdftops die.pdf
# produces die.ps
mv die.pdf die.pdf.bak
pstopdf die.ps
# produces a correct die.pdf file
The new PDF file caused no problems.
Extract images from PDF
pdfimages -j foo.pdf bar
Extract all images from foo.pdf, save them in JPG format (-j), and rename them to bar-001.jpg, bar-002.jpg, etc.
This tip is from here.
Resize .tif file and convert to .jpg
Use case
In the lab we have a photocopier that can scan too. Quite cool, you can precise your email address and it sends you the scanned page in .tif format.
However, pages must be scanned one by one and each of them is sent as a separate .tif file. Each .tif file is around 2.8 MB large with a resolution of 4900 x 7000 pixels. How to resize them and convert them to .jpg files? Gimp is one way but could we solve it in command-line?
Solution
Put the .tif files in a folder and create a subfolder called “out”. This way the output won’t be mixed with the input.
for i in *.tif; do echo $i; convert $i -resize 24% out/`basename $i .tif`.jpg; done
Each .tif is made smaller (width around 1200 pixels) and converted to .jpg.
As a final touch, convert the JPGs to a PDF file.
cd out convert *.jpg doc.pdf
Question
Does anyone know how to to resize an image the following way: let width be 1200 pixels and keep the aspect ratio? Above the 24% was the result of a manual computation…
Answer: just use “convert -resize 1200 in.tif out.jpg“. The output will have width=1200 pixels with the same ratio as the input image. (Thanks Yves for the tip.)
Reduce the size of a PDF file
Problem
You produce a PDF but it’s too big. How to reduce its size?
Solution
Make a much smaller PDF. Note that images will be quite ugly.
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
The PDF will be a bit smaller. Images remain in good quality.
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
For more possible values of PDFSETTINGS, see this page.
Ref.: here.
Translate a PDF file
Problem
Today, at Ubuntu Life I found a post (in English) with a 60-page long PDF manual that contains Ubuntu tips. I downloaded it naively but it was in Spanish! :)) Great! I don’t speak Spanish… What to do? How to translate a PDF file?
Solution
Well, my solution is not an elegant one. I would say that it falls in the category “better than nothing”.
Steps:
- Get the PDF.
- Extract the text from it with “pdftotext file.pdf file.txt”.
- Make an HTML out of file.txt: rename it to file.html, and add the header <pre> as the first line and the footer </pre> as the last line.
- Upload the file to a public place. Easiest way: put in your Dropbox/Public folder.
- Translate the public HTML file with Google Translate.
- If Google Translate doesn’t translate the whole text, then it’s too long. Cut it into several pieces.
The end result is an ugly text file, but at least you can have an idea what it’s about.
If you have a more sophisticated solution, don’t hold it back.
Edit your PDF files
Problem #1
You have a PDF file and you want to remove some pages from it. You want to do this job via a GUI interface.
Solution #1
You can use PDF Mod for this task.
“PDF Mod is a simple application for modifying PDF documents. You can reorder, rotate, and remove pages, export images from a document, edit the title, subject, author, and keywords, and combine documents via drag and drop.” (source)
It exists in the repositories, but if you want the latest version, install it from PPA:
sudo add-apt-repository ppa:pdfmod-team/ppa sudo apt-get update sudo apt-get install pdfmod
The PPA tip is from Ubuntu Geek.
Problem #2
You want to modify your PDF files from the command line.
Solution #2
Check out my post on pdftk.
Related links
- PyPdf module (Python)
