Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: creating pdfs with a2ps< Next Oldest | Next Newest >
reidar Offline





Group: Members
Posts: 92
Joined: Sep. 2004
Posted: Sep. 15 2004,07:20 QUOTE

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
Back to top
Profile PM 
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: Sep. 16 2004,02:58 QUOTE

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
Back to top
Profile PM MSN YIM 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Sep. 16 2004,04:29 QUOTE

Chris, Thanks for sharing. Will put that emelfm option in the next release.
Back to top
Profile PM WEB 
reidar Offline





Group: Members
Posts: 92
Joined: Sep. 2004
Posted: Sep. 16 2004,06:45 QUOTE

Hey, that's a great idea Chris! Thanks a lot! I will try this at once.
:)

-r
Back to top
Profile PM 
clivesay Offline





Group: Guests
Posts: 935
Joined: Dec. 2003
Posted: Sep. 16 2004,09:38 QUOTE

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
Back to top
Profile PM MSN YIM 
6 replies since Sep. 15 2004,07:20 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: creating pdfs with a2ps

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code