opendocument-users message
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]
Subject: Re: [opendocument-users] scripting, odf2ps?
- From: robert_weir@us.ibm.com
- To: phil@five-lawrences.com
- Date: Tue, 10 Jan 2006 14:21:27 -0500
> Questions:
> 1. Can anyone recommend a favorite Language/API for scripting
the
> creation of these invoices? They will include tables with borders,
> some graphics, etc. An existing method of templating documents
would
> be great.
I'd certainly recommend using your favorite language/API
for scripting OpenDocument. Why waste your time on any of those other
languages? <g>
But seriously, Phil, any language that allows you
to write text to a file would be fine. Language like Java which have
libraries for creating zip files are nice as well, though you could always
shell out for that from your language of choice, if needed. OpenDocument
today is purely a specification for an XML format. There is no standard
for an API for manipulating/creating ODF documents, other than existing
standards like DOM, SAX, etc. But I think it would be a killer tool,
if we had a higher-level API that dealt in domain-level constructs like
pages, paragraphs, cells, rather than the lower level XML abstraction of
elements and attributes.
But until that happens, one idea I'll suggest is this:
1) create a template that has the basic structure
and content you want. Put placeholder values for things that will
be replaced when creating the invoice, such as _COMPANY_NAME, _COMPANY_ADDRESS_1,
etc.
2) Parse the template XML into a DOM.
3) Using the DOM API, modify the DOM according to
the invoice you are working on. In other words, replace the placeholders
with real values.
4) Serialize the resulting DOM back to an XML file,
and zip up the results to get your new ODF document
This approach works well if you are generating a large
number of invoices as part of a batch job, since you are parsing the template
ODF file only once.
> 2. For actually printing the documents, are there any ODF to
> postscript or PDF utilities, i.e. something I can pipe to lp? (I'll
> be developing on OS X.)
I haven't tried it myself, but I wonder if Apache's
FOP project might help? That converts XSL:FO XML into PDF or PS(and
other formats as well). That doesn't solve your problem entirely,
but reduces it to converting ODF XML to XSL:FO XML, which is a more tractable
problem.
-Rob
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
| [List Home]