creating pdfs with a2ps


Forum: Other Help Topics
Topic: creating pdfs with a2ps
started by: reidar

Posted by reidar on 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

Posted by clivesay on Sep. 16 2004,02:58
reidar -

I'll add something for the non-commandline people.   :p

In Emelfm, Click on the "Configure" button. When the menu comes up, choose "button" and click add. Give your button a name like "Create PDF". In the command field type:
Code Sample
a2ps -R --columns=1 --borders=0 -B -P pdf %f


Now when you highlight test.txt in emelfm, click the "Create PDF" button and there you have it!! :)

HTH

Chris

Posted by roberts on Sep. 16 2004,04:29
Chris, Thanks for sharing. Will put that emelfm option in the next release.
Posted by reidar on Sep. 16 2004,06:45
Hey, that's a great idea Chris! Thanks a lot! I will try this at once.
:)

-r

Posted by clivesay on Sep. 16 2004,09:38
Wow, I didn't know it was THAT good of an idea, roberts!! :;): Thanks

reidar, I was just playing around after I read your post. A few people helped me with creating emelfm buttons a few months ago so when I saw your post, the lightbulb came on! The "%f" represents the selected file. You might play around with creating buttons with some of your other commandline tools. You might convert to GUI! :p

Take care

Chris

Posted by reidar on Sep. 16 2004,10:18
Hehe. I am not really against GUI. I believe the combination of command line and GUI is very important and powerful. Linux is superior there in my opinion (and of course it is also superior in lots of other areas as well...)!

It is very interesting to see how the GUI tools are connected with commands. Thereby I feel that I get a deeper understanding of the tools, and that is far much better than mindless button-pushing! (Not that I believe that anyone in this forum are mindless button-pushers of course!!!)

But thanks again for the hint!
:)

-r

Posted by clivesay on Sep. 16 2004,10:28
I completely agree with you. I have started writing some bash scripts so now when I want to do something at work I think, "If I only had bash......" :angry:

:)

Chris

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.