Skip to content

Commit 0b99cc7

Browse files
committed
prepare 0.7.0
1 parent 96a2173 commit 0b99cc7

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

README.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Gem for generating .odt files by making strings, images, tables and sections rep
55

66
### NEW
77

8-
* uses newer rubyzip >= **1.3.0**
8+
* allow nested images inside tables and sections
9+
* allow sections inside tables
910

1011
## INSTALL
1112

@@ -28,7 +29,7 @@ There are *four* kinds of substitutions available:
2829

2930
#### Fields
3031

31-
It's just an upcase sentence, surrounded by brackets. It will be replaced for wathever value you supply.
32+
It's just an upcase sentence, surrounded by brackets. It will be replaced by the value you supply.
3233

3334
In the folowing example:
3435

@@ -79,21 +80,7 @@ and a collection `@list_of_itens`, it will create one row for each item in the c
7980

8081
Any format applied to the fields in the template will be preserved.
8182

82-
83-
### Images
84-
85-
You must put a mock image in your `.odt` template and give it a name. That name will be used to replace the mock image for the actual image.
86-
You can also assign any properties you want to the mock image and they will be kept once the image is replaced.
87-
88-
An image replace would look like this:
89-
90-
```ruby
91-
report = ODFReport::Report.new("my_template.odt") do |r|
92-
r.add_image :graphic1, "/path/to/the/image.jpg"
93-
end
94-
```
95-
96-
### Sections
83+
#### Sections
9784

9885
Sometimes, you have to repeat a whole chunk of a document, in a structure a lot more complex than a table. You can make a Section in your template and use it in this situations. Creating a Section in OpenOffice is as easy as select menu *Insert* and then *Section...*, and then choose a name for it.
9986

@@ -146,6 +133,26 @@ Note that when you add a Table to a Section, you don't pass the collection itsel
146133

147134
In the above example, `s.add_table("TB_ITEMS", :items, header: true) do |t|`, the `:items` thing refers to a `invoice.items`. Easy, right?
148135

136+
137+
#### Images
138+
139+
You must put a mock image in your `.odt` template and give it a name. That name will be used to replace the mock image for the actual image.
140+
You can also assign any properties you want to the mock image and they will be kept once the image is replaced.
141+
142+
An image replace would look like this:
143+
144+
```ruby
145+
report = ODFReport::Report.new("my_template.odt") do |r|
146+
r.add_image :graphic1, "/path/to/the/image.jpg"
147+
148+
r.add_table("TABLE_WITH_IMAGES", @items) do |t|
149+
t.add_column(:id)
150+
t.add_column(:product, :product_name)
151+
t.add_image('PRODUCT_IMAGE') { |item| item.image_path }
152+
end
153+
end
154+
```
155+
149156
<hr/>
150157

151158
### Step 2 -- generating the document
@@ -213,5 +220,6 @@ report = ODFReport::Report.new(io: @template.attachment.read) do |r|
213220

214221
#### REQUIREMENTS
215222

216-
**rubyzip**: for manipulating the contents of the odt file, since it's actually a zip file.
217-
**nokogiri**: for parsing and manipulating the document xml files.
223+
**rubyzip**: manipulating the contents of the odt file, since it's actually a zip file.
224+
**nokogiri**: parsing and manipulating the document xml files.
225+
**mime-types**: identify images mime types

lib/odf-report/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ODFReport
2-
VERSION = "0.6.1"
2+
VERSION = "0.7.0"
33
end

0 commit comments

Comments
 (0)