reidar
Group: Members
Posts: 92
Joined: Sep. 2004 |
|
Posted: Sep. 15 2004,07:20 |
|
I am not sure if anyone will find this interesting, but it was a great discovery for me, so here it goes:
I wanted to see if I could create a pdf-document from the command line, with nothing but the tools available in the "native" dsl, meaning not using any add-on packages. Now, I know it is possible to create pdf-files by typing a text in Ted, printing it to a file to get a .ps and then use ps2pdfwr to get a pdf-file, but I wanted to use nothing but command-line, to see if it was possible, and to learn something new. Here is what I did:
I found out that dsl comes with a tool called a2ps, which supposedly can make postscript out of just about anything. I think it normally is for communicating with postscript printers or something, but you can also create pdfs with it.
First I typed a sample text, and saved it as test.txt. The first times I used vi to create the text, but then I figured out it was even more cool (...crazy, whatever you want to call it...) to do it using 'cat > test.txt'. Then I didn't even need to use a text-editor. When I had finished typing i used CTRL-c to exit the "cat-writer", and I had created a text called test.txt.
Now to create a pdf-file of that text with a2ps I had to play around for a while, and try out lots of possibilities, but I finally found out how to create a clean, neat pdf-file. Here is my solution:
$a2ps -R --columns=1 --borders=0 -B -P pdf test.txt
The outcome was a pdf-file called test.pdf. Just to explain: -R put the file in portrait-mode (default was landscape), --columns=1 created a page with only one column (default seemed to be two columns), --borders=0 assured I wouldn't get a border wrapping my text (which seemed to be default), -B made sure I didn't get any headers (which again was default), and finally -P pdf assured that the file was sent to a pdf-printer, creating a pdf-file.
Some of you have probably figured out that I am very fond of pdf-files, and this was quite a revelation for me. Hope some of you find it ... well, if not useful, then at least amusing, or interesting to see what you can actually do from a command-line. Anyway. Cool I think!!
-r
|