README.md in caracal-1.0.2 vs README.md in caracal-1.0.3

- old
+ new

@@ -88,10 +88,11 @@ |- _rels |- .rels |- docProps |- app.xml |- core.xml + |- custom.xml |- word |- _rels |- document.xml.rels |- media |- image001.png @@ -117,10 +118,13 @@ Specifies the name of the application that generated the document. *This file is generated automatically by the library based on other user directives.* **docProps/core.xml** Specifies the title of the document. *This file is generated automatically by the library based on other user directives.* +**docProps/custom.xml** +Specifies the custom document properties. *This file is generated automatically by the library based on other user directives.* + **word/_rels/document.xml.rels** Defines an internal identifier and type with all external content items (images, links, etc). *This file is generated automatically by the library based on other user directives.* **word/media/** A collection of media assets (each of which should have an entry in document.xml.rels). @@ -165,18 +169,18 @@ **Pixels** In Word documents, pixels are equivalent to points. **EMUs (English Metric Unit)** -EMUs are a virtual unit designed to facilitate the smooth conversion between inches, milliimeters, and pixels for images and vector graphics. 1in == 914400 EMUs == 72dpi x 100 x 254. +EMUs are a virtual unit designed to facilitate the smooth conversion between inches, millimeters, and pixels for images and vector graphics. 1in == 914400 EMUs == 72dpi x 100 x 254. At present, Caracal expects values to be specified in whichever unit OOXML requires. This is admittedly difficult for new Caracal users. Eventually, we'll probably implement a utility object under the hood to convert user-specified units into the format expected by OOXML. ## Syntax Flexibility -Generally speaking, Caracal commands will accept instructions via any combination of a parameters hash and/or a block. For example, all of the folowing commands are equivalent. +Generally speaking, Caracal commands will accept instructions via any combination of a parameters hash and/or a block. For example, all of the following commands are equivalent. ```ruby docx.style id: 'special', name: 'Special', size: 24, bold: true docx.style id: 'special', size: 24 do @@ -349,24 +353,43 @@ * Heading4 * Heading5 * Heading6 + +### Custom Properties + +Custom document properties can be defined using the `custom_property` method. The method accepts a few required parameters to control the definition of the custom property. + +```ruby +docx.custom_property do + name 'property name 1' # sets the name of the custom property. + value 'test' # sets the value of the custom property. + type :text # sets the property type. accepts :text, :number, :date, :boolean. +end +``` + +The `name`, `value`, and `height` attributes are required. If any of the attributes are missing, the custom property will not be created. + +A document may have zero or many custom properties. Each custom property's `name` should be unique with its `type`. + + + ### Paragraphs -Paragraph text can be added using the `p` method. The method accepts several optional parameters for controlling the style and behavior of the paragrpah. +Paragraph text can be added using the `p` method. The method accepts several optional parameters for controlling the style and behavior of the paragraph. In its simple form, a paragraph accepts a text string and formatting options. ```ruby docx.p 'Sample text.' docx.p 'Sample text.', style: 'custom_style' docx.p 'Sample text.' do style 'custom_style' # sets the paragraph style. generally used at the exclusion of other attributes. - align :left # sewts the alignment. accepts :left, :center, :right, and :both. + align :left # sets the alignment. accepts :left, :center, :right, and :both. color '333333' # sets the font color. size 32 # sets the font size. units in 1/2 points. bold true # sets whether or not to render the text with a bold weight. italic false # sets whether or not render the text in italic style. underline false # sets whether or not to underline the text. @@ -382,10 +405,11 @@ link 'link', 'https://www.example.com' text ' to something awesome', font: 'Courier New', color: '555555', size: 32, bold: true, italic: true, underline: true, bgcolor: 'cccccc' text '.' br text 'This text follows a line break.' + page end ``` ### Links @@ -563,10 +587,10 @@ ```ruby docx.table [['Header 1','Header 2'],['Cell 1', 'Cell 2']] do border_color '666666' # sets the border color. defaults to 'auto'. border_line :single # sets the border style. defaults to :single. see OOXML docs for details. border_size 4 # sets the border width. defaults to 0. units in twips. - border_spacing 4 # sets the spacing around the border. deaults to 0. units in twips. + border_spacing 4 # sets the spacing around the border. defaults to 0. units in twips. end ``` Table borders can be further styled with position-specific options. Caracal supports styling the top, bottom, left, right, inside horizontal, and inside vertical borders with the `border_top`, `border_bottom`, `border_left`, `border_right`, `border_horizontal`, and `border_vertical`, respectively. Options have the same meaning as those set at the table level.