Showing posts with label split. Show all posts
Showing posts with label split. Show all posts

Friday, August 14, 2009

linux: how to insert an img to pdf files

If you want to insert an image (like your picture, signature etc.) to an existing pdf file and you don't have acrobat professional version (that allows you to edit a pdf file within the software). Then you may be able to use the following steps with combination of different tools that are available in linux:

  1. You have an image file (say, one lovely picture) and one pdf file (Orig.pdf) to which you want to insert your picture
  2. Use "gimp" to open them. For the pdf file, you have to select which page that you want to insert your picture to, and then open the page (NOTE: in order to have good quality and same size as the original page, you may have to set "resolution" as 320. I tried 300 and 400, and realized that 320 is the proper value)
  3. In "gimp", copy your picture on the pdf page. You can use the menu "Layer -> Scale Layer ..." to scale your picture to fit your requirement.
  4. Save your modified pdf page as one "eps" file.
  5. In terminal, convert the eps file to a pdf file by "epstopdf MyPage.eps" to get MyPage.pdf
  6. Then, still in your terminal, use the tool "pdftk" to merge the 2 pdf files (Orig.pdf and MyPage.pdf):
pdftk A=Orig.pdf B=MyPage.pdf cat A1-4 B1 A6-11 output Combined.pdf
where we assume MyPage.pdf will be inserted as Page 5 while totoal pages in Orig.pdf are 11 pages.

Merge pdf files:

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

Saturday, November 8, 2008

Linux:shell: awk: multiple separators

'awk' is a very useful shell command (also a program language) in linux (unix). You split one text line by it. For example, for the line

line="aa, b c , d , f "

what you can do in shell command (bash) is

echo $line|awk -F "," '{print $1 $2 $3 $4}' # to get different columns separated by ","

However, if you wanna split one line with multi-separators, then you could do in the way, for example,

$ line="aa, bb_ ccd: ee"
$ echo $line |awk -F ",|_|:" '{print $1$2$3}'

Note here "|" will do logic "OR" of all separators. This is similar 'egrep'. If you want to grep multi key words, then you could do in the same way (which has been addressed in my other blog, just search grep ).

Friday, November 30, 2007

linux: how to merge/split pdf files

In linux, there is no professional acrobat avaible, which means that sometimes if you edit your pdf files, for example, merge, split pdf files, you may not have clue to do that. Lots of ppl in the net would recommend "pdftk" (pdf toolket) for you. I try to install, but some lib is needed. I have no time to install other dependent lib so I recalled I have a java tool: Multivalent. Just google it and find its page.

Usage:
java -classpath ~/Multivalent20060102.jar tool.pdf.Merge file1.pdf file2.pdf ...

That is it. You also can split your pdf file to separated ones. Of course, you need to download Multivalent20060102.jar from somewhere of the net. Yes, you can use "convert" to merge, but bad resolution and very slow, not recommended.

Locations of visitors to this page