2015. április 30.

color to grayscale PDF

The source file:
a PDF with page size US letter portrait
with text layer (different color and text background varying)
with color images as background (many images sum up to one background picture

The quest: convert the source PDF to:
a PDF with page size A4 portrait
with or without text layer (flatten or not - but keep text readable)
with grayscale and/or black and white (but recognizable) images as background

The purpose: print out the pdf on a regular black-and white printer:
keep it readable, and esthetically enjoyable
do not use more ink than necessary

***
The routes I tried:

1.) (from under the text layer) extract images, convert images, put images back.

Toolkit:

Extract images:
pdf2htmlEX --embed cfijo example.pdf

Convert images:
mogrify -type Grayscale -format ps *.png

...convert back to pdf with ps2pdf, join with pdfjoin or pdftk

Extract text layer:  
cpdf -draft example.pdf -o example_text.pdf

Put background images behind text layer:
pdftk  example_text.pdf multibackground example_images.pdf output modified.pdf


2.) flatten PDF to images, edit images.

Toolkit:

Burst pdf to single pages:
pdftk example.pdf burst

Convert to PostScript:
pdftops (and not pdf2ps)

Flatten ps to pnm and edit image
mogrify -format pnm -density 200x200 -type grayscale *.ps

...convert back to pdf with ps2pdf, join with pdfjoin or pdftk



***
In the end I chose the second route, because I had some trouble with the fonts in the pdf, which were not exported properly, and left a black text box in the images (making the text unreadable after backgrounding back to pdf)

Also the first route would involve a lot of learning of the PDF structure, the layer manipulation, and so on.

2015. április 26.

How to turn off ubuntu overlay scrollbar

https://www.liberiangeek.net/2012/03/disable-ubuntu-overlay-scrollbars-in-ubuntu-12-04-precise-pangolin/

~$ gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars false

This can be set by hand in dconf editor:

org > gnome > desktop > interface > ubuntu -overlay-scrollbars [remove checkmark]

2015. április 8.

Command Line alternative to Safely Remove Drive

Recently my external USB drives (HDD, Pendrive, Kindle, mobile phone) stopped detaching itself after unmount.
Obviously I would not plug out a HDD with 750GB data that is still spinning. But it does not want to stop at all. I can mount and umount it and it is still spinning. (Or whatever these new drives does instead of spinning)

So the solution is to do the command line equivalent of safely remove in two steps:
1. unmount
2. detach

The solution I found on askubuntu:

For a practical example, if I have the partition /dev/sdb1 mounted, I would run this to unmount and detach it:
udisks --unmount /dev/sdb1
udisks --detach /dev/sdb