documenter

Documenter is small collection of scripts to work with different format of documents It includes:

  • Odf and Odt classes to fill forms, tables and e.t.c

  • File format convertor based on JodConvertor. To work with it, you need to have open office istalled localy

  • Pdf worker based on pdftk. You should install it too

  • Csv class to work with csv more easely

Installation

% gem install documenter

Example

Csv

Load data from file into two demetions array data = File.open(‘test.csv’).csv(:cell_split => ‘;’)

Export data to csv file data.to_csv(:file => ‘myout.csv’, :header => [‘a’,‘a+100’], :cell_split => ‘;’)

Convertor

Convertor.convert ‘test.xls’, ‘test.pdf’

Pdf

Join files together

Pdf.cat [‘a.pdf’,‘b.pdf’], ‘output.pdf’

Split pdf to pages second parameter - string that would be used as a pattern to save each page

Pdf.burst ‘hello.pdf’, ‘doc/page_%.6d.pdf’

#opening existing document doc = OdtFile.new ‘custom_register.odt’ #set value of form field doc.text.fill_form(‘number’ => ‘test’) #search for table and yield first row copy for each data row doc.text.edit_table(:name => ‘posts’, :data =>posts) do |row, content|

#replace form fields
row.replace_form(content)
#we shoul return row back
row

end doc.save ‘out.odt’ #you should use close to delete temporary files doc.close