Other Help Topics :: creating pdfs with a2ps



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

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

Chris, Thanks for sharing. Will put that emelfm option in the next release.
Hey, that's a great idea Chris! Thanks a lot! I will try this at once.
:)

-r

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

Next Page...
original here.