Ruby & Preprinted forms - will they work together?

I’m a Ruby newbie, but I’ve decided to write a commercial application
using Ruby. This application needs the capability to print on a
pre-printed form. Can Ruby do this?

I’ve been writing it in Lotus Notes, but I will need to spend a
considerable amount of money for software that will standardize the
print, regardless of the printer. Writing it in Ruby, using FXRuby and
FreeRIDE, will give me some great experience with Ruby.

I don’t want to get started, however, if the consensus is that Ruby
can’t handle my printing needs.

Thanks in advance,

John Reed
colotechpro@yahoo.com

This might not appeal unless you have some TeX experience, but I’ve had
a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby. The approach I take is to
have the Ruby code generate all the values, and then call a templating
library (actually the one I wrote for RDoc) to substitute those values
into a LaTeX document. I then format this, and present the results to
the end user as PDFs. I write a fairly simple style sheet for each
document type, and the templates invoke macros in these style sheets.
Using LaTeX (TeX) gives me precise control over positioning of the
fields on the paper.

Cheers

Dave

···

On Fri, 2002-12-27 at 15:11, John Reed wrote:

I’m a Ruby newbie, but I’ve decided to write a commercial application
using Ruby. This application needs the capability to print on a
pre-printed form. Can Ruby do this?

I’ve been writing it in Lotus Notes, but I will need to spend a
considerable amount of money for software that will standardize the
print, regardless of the printer. Writing it in Ruby, using FXRuby and
FreeRIDE, will give me some great experience with Ruby.

Cool! But how do you convert from LaTeX to PDF?

(Sorry if a stupid question…)

Chris

“Dave Thomas” dave@thomases.com wrote in message

This might not appeal unless you have some TeX experience, but I’ve had
a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby.

Is this code available anywhere for public consumption ?

The approach I take is to have the Ruby code generate all the values,
and then call a templating
library (actually the one I wrote for RDoc) to substitute those values
into a LaTeX document. I then format this, and present the results to
the end user as PDFs.

Is conversion from LaTeX to PDF fairly easy and multi-platform ?

I write a fairly simple style sheet for each document type, and the
templates invoke macros in these style sheets.
Using LaTeX (TeX) gives me precise control over positioning of the
fields on the paper.

Awesome !

You will want to obtain pdflatex - this is what I use to convert
my LaTeX files to pdf

As to how you obtain it is up to you.

···

On Friday, December 27, 2002, at 11:22 PM, Chris Pine wrote:

Cool! But how do you convert from LaTeX to PDF?

(Sorry if a stupid question…)

Chris

a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby.

Is this code available anywhere for public consumption ?
it comes with most linux distributions.

On Windows you might want to look at MikTeX
http://www.miktex.org/

more links:
http://directory.google.com/Top/Computers/Software/Typesetting/TeX/LaTeX/?tc=1

Is conversion from LaTeX to PDF fairly easy and multi-platform ?
use pdflatex – that saves you some problems with fonts.
Alternatively on linux use:
dvips and then ps2pdf
These packages rely on ghostscript – I think.

LaTeX takes some time to get used to, but
once you know it, you might not want to go
back.

Good luck,
-A

···

Armin Roehrl, http://www.approximity.com
Training, Development and Mentoring
OOP, XP, Java, Ruby, Smalltalk, Datamining, Parallel computing, Webservices

“Dave Thomas” dave@thomases.com wrote in message

This might not appeal unless you have some TeX experience, but I’ve had
a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby.

Is this code available anywhere for public consumption ?

The templating code is based on the one in RDoc. In this particular
application, I use the same templating code to do web pages, XML,
e-mail, and LaTeX.

I could post it separately somewhere if folks want.

Is conversion from LaTeX to PDF fairly easy and multi-platform ?

I use pdflatex under Linux – I’ve never tried it under Windows, but I
suspect there’s something similar. In my experience, pdflatex produces
better output than using straight LaTeX and then converting the dvi or
postscript to PDFs.

Cheers

Dave

···

On Fri, 2002-12-27 at 17:32, Shashank Date wrote:

“Shashank Date” sdate@kc.rr.com wrote in message news:sp5P9.37995$Zt4.454486@twister.rdc-kc.rr.com

Is conversion from LaTeX to PDF fairly easy and multi-platform ?

Yes, the easiest way is to use pdflatex which outputs PDF files
instead of the usual DVI files

I write a fairly simple style sheet for each document type, and the
templates invoke macros in these style sheets.
Using LaTeX (TeX) gives me precise control over positioning of the
fields on the paper.

Awesome !

It’s even easier now that Ruby (1.8) includes ‘erb.rb’ templating
library.

Francois

Dave Thomas wrote:

···

On Fri, 2002-12-27 at 17:32, Shashank Date wrote:

“Dave Thomas” dave@thomases.com wrote in message

This might not appeal unless you have some TeX experience, but I’ve had
a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby.

Is this code available anywhere for public consumption ?

The templating code is based on the one in RDoc. In this particular
application, I use the same templating code to do web pages, XML,
e-mail, and LaTeX.

I could post it separately somewhere if folks want.

YES! Please.


Wai-Sun “Squidster” Chia
Consulting & Integration
Linux/Unix/Web Developer Dude
“Just Another Ruby Miner”

You will want to obtain pdflatex - this is what I use to convert
my LaTeX files to pdf

Or use “plain” latex with dvips and ps2pdf if you find
you need a feature not supported by pdflatex, e.g.
including eps graphics.

works very well. we’ve produced a book with this method.

s.

···

On Sat, 28 Dec 2002 09:29:02 +0900, Chris Ross chris@darkrock.co.uk wrote:

As to how you obtain it is up to you.

On Friday, December 27, 2002, at 11:22 PM, Chris Pine wrote:

Cool! But how do you convert from LaTeX to PDF?

(Sorry if a stupid question…)

Chris

Thanks to all !

“Armin Roehrl” armin@xss.de wrote in message
news:200212280226.16561.armin@xss.de

a lot of luck generating fairly complex financial forms (multi-page
invoices, statements, and so on) using Ruby.

Is this code available anywhere for public consumption ?
it comes with most linux distributions.

On Windows you might want to look at MikTeX
http://www.miktex.org/

more links:

http://directory.google.com/Top/Computers/Software/Typesetting/TeX/LaTeX/?tc
=1

Is conversion from LaTeX to PDF fairly easy and multi-platform ?
use pdflatex – that saves you some problems with fonts.
Alternatively on linux use:
dvips and then ps2pdf
These packages rely on ghostscript – I think.

LaTeX takes some time to get used to, but
once you know it, you might not want to go
back.

Good luck,
-A

Armin Roehrl, http://www.approximity.com
Training, Development and Mentoring
OOP, XP, Java, Ruby, Smalltalk, Datamining, Parallel computing,
Webservices

···

OK - unsupported and all the usual caveats…

Download Template.rb (RDoc: NO LONGER ACTIVE—part of Ruby)

Cheers

Dave

···

On Fri, 2002-12-27 at 19:52, Wai-Sun Chia wrote:

The templating code is based on the one in RDoc. In this particular
application, I use the same templating code to do web pages, XML,
e-mail, and LaTeX.

I could post it separately somewhere if folks want.

YES! Please.

I was looking around for a decent template system, and RDoc’s fit the
bill for me, almost. I had some perfectly good objects lying around
with perfectly good methods on them, and didn’t want to go through the
extra (tedious) step of converting them all to Hash/Array combinations,
so I did this to (a prior version of) RDoc’s template system:

http://segment7.net/ruby-code/template/template.rb
(more/better description there)

and tests:

http://segment7.net/ruby-code/template/TC_template.rb

NOTES:
My version is faster, mainly because I don’t use an Array to build
up a temporary object, but you can’t write onto anything but a string.
I haven’t bothered to attempt to fix this yet (it hasn’t been a
problem for me).

My version has slightly different syntax for iteration (FOREACH/ENDEACH),
due to the addition of WITH/ENDWITH.

···

Dave Thomas (dave@pragprog.com) wrote:

On Fri, 2002-12-27 at 19:52, Wai-Sun Chia wrote:

The templating code is based on the one in RDoc. In this particular
application, I use the same templating code to do web pages, XML,
e-mail, and LaTeX.

I could post it separately somewhere if folks want.

YES! Please.

OK - unsupported and all the usual caveats…

Download Template.rb (RDoc: NO LONGER ACTIVE—part of Ruby)


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Thanks for the excellent ideas.

John

Dave Thomas dave@thomases.com wrote in message news:1041048529.8665.201.camel@zip

···

On Fri, 2002-12-27 at 19:52, Wai-Sun Chia wrote:

The templating code is based on the one in RDoc. In this particular
application, I use the same templating code to do web pages, XML,
e-mail, and LaTeX.

I could post it separately somewhere if folks want.

YES! Please.

OK - unsupported and all the usual caveats…

Download Template.rb (RDoc: NO LONGER ACTIVE—part of Ruby)

Cheers

Dave

you can use RDoc for general purpose templating? i thought it was only for
documenting Ruby code. (I checked RDoc web page but didn’t see any reference
to this type of use.)

what do the templates look like in doing this?

currently i use eRuby. I would have liked to use Amrita, but it seems the
attribute templating is still considered experimental.

i’m curious as to the relative performace comparisons between the various
templating options. anyone have any experience to draw upon for this?

-transami

···

On Saturday 28 December 2002 12:22 am, Eric Hodel wrote:

I was looking around for a decent template system, and RDoc’s fit the
bill for me, almost. I had some perfectly good objects lying around
with perfectly good methods on them, and didn’t want to go through the
extra (tedious) step of converting them all to Hash/Array combinations,
so I did this to (a prior version of) RDoc’s template system:

currently i use eRuby. I would have liked to use Amrita, but it seems the
attribute templating is still considered experimental.

If you’re talking about attribute expansion; yes it is still ‘experimental’
(as of 1.0), but I speak from experience when I say it is definitely working.
I use amrita for the vast majority of my web projects (in the past I used
eruby) and attribute expansion has never been a problem. I’m guessing it is
only considered “experimental” due to the fact its implementation may be
changed sometime in the future (I defer to Nakajima-san for further details
and/or clarification).

i’m curious as to the relative performace comparisons between the various
templating options. anyone have any experience to draw upon for this?

-transami

Eruby/erb is decidedly faster than amrita due to the way data is applied to
the templates (amrita actually understands the template ‘context’ when the
data is applied, enabling it to apply sequences repetatively, etc-- this
“smart” templating comes at an obvious perfomance cost)-- other templating
libraries blindly insert data, IIRC. Amrita is, of course, an excellent
choice for static page creation, but I would caution using it in larger,
heavy bandwidth projects where templates would be expanded dynamically.
Speed optimization is definitely one of the chief areas of concern in Amrita
development; I’m sure the situation will become more amenable in the future
as the project matures.

Hope this helps,

~ Bruce

···

On Saturday 28 December 2002 02:31 am, Tom Sawyer wrote:


Bruce R. Williams :: [iusris/#ruby-lang] :: http://www.codedbliss.com

‘It does not require a majority to prevail, but rather an irate,
tireless minority keen to set brush fires in people’s minds.’
– Samuel Adams

I was looking around for a decent template system, and RDoc’s fit the
bill for me, almost. I had some perfectly good objects lying around
with perfectly good methods on them, and didn’t want to go through the
extra (tedious) step of converting them all to Hash/Array combinations,
so I did this to (a prior version of) RDoc’s template system:

you can use RDoc for general purpose templating? i thought it was only for
documenting Ruby code. (I checked RDoc web page but didn’t see any reference
to this type of use.)

Well, no, but I attended RubyConf, and Dave hinted at such a thing in
RDoc, so I looked in there, found it, stole it, and hacked it up :slight_smile:

what do the templates look like in doing this?

Using my hacked version, you do something like this:

Usage:

···

Tom Sawyer (transami@transami.net) wrote:

On Saturday 28 December 2002 12:22 am, Eric Hodel wrote:

T1 = %{header

!INCLUDE!

footer}

T2 = %{%name%

%state%

letters in name: %name.size%}

values = { “name” => “Dave”, “state” => “TX” }

t = TemplatePage.new(T1, T2)

res = ‘’

t.write_html_on(res, values)

Which will result in the following

output:

header

Dave

TX

letters in name: 4

footer

For a fancier template, you could do something like:

require ‘template’

T = %{

Object contains these WITH:Object#methods %Array#length% ENDWITH:Object#methods methods:

    FOREACH:Object#methods
  • %String#to_s% ENDEACH:Object#methods
}

res = ‘’

TemplatePage.new(T).write_html_on(res, Object.new)

puts res

currently i use eRuby. I would have liked to use Amrita, but it seems the
attribute templating is still considered experimental.

eRuby is very slow, as it eval’s a tempfile to generate the page.

i’m curious as to the relative performace comparisons between the various
templating options. anyone have any experience to draw upon for this?

Well, anything in pure ruby is going to be slower than a pure C version.
How much faster or slower will be dependent upon features offered.
RDoc’s and mine are pretty much brain-dead simple, and I hacked mine to
up the speed (I took out a call to Array#join that really sucked down
performance, and eliminated RegExp as much as convenient, in favor of
String#).


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

currently i use eRuby. I would have liked to use Amrita, but it seems the
attribute templating is still considered experimental.

If you’re talking about attribute expansion; yes it is still ‘experimental’
(as of 1.0), but I speak from experience when I say it is definitely working.
I use amrita for the vast majority of my web projects (in the past I used
eruby) and attribute expansion has never been a problem. I’m guessing it is
only considered “experimental” due to the fact its implementation may be
changed sometime in the future (I defer to Nakajima-san for further details
and/or clarification).

I agree with you. I think “attribute expansion” is working well .

amrita’s experimental features are experimental partly because they
are not tested enough. But main reason is it’s easy to add a feature
but difficult to remove one once it was released and get users.

i’m curious as to the relative performace comparisons between the various
templating options. anyone have any experience to draw upon for this?

-transami

Eruby/erb is decidedly faster than amrita due to the way data is applied to
the templates (amrita actually understands the template ‘context’ when the
data is applied, enabling it to apply sequences repetatively, etc-- this
“smart” templating comes at an obvious perfomance cost)-- other templating
libraries blindly insert data, IIRC. Amrita is, of course, an excellent
choice for static page creation, but I would caution using it in larger,
heavy bandwidth projects where templates would be expanded dynamically.
Speed optimization is definitely one of the chief areas of concern in Amrita
development; I’m sure the situation will become more amenable in the future
as the project matures.

Recently a good idea of new compiler architecture came to me . I think
the new version of amrita will produce a Ruby code as fast as a plain
Ruby. And it will also generate a C code (extention module) that runs
faster than a Ruby equivalent.

···

At Sat, 28 Dec 2002 17:16:45 +0900, Bruce Williams wrote:

On Saturday 28 December 2002 02:31 am, Tom Sawyer wrote:


Taku Nakajima
http://www.walrus-ruby.org/amrita/