0

This is working code to add the paragraph in rtf file.

document = Document.new(Font.new(Font::ROMAN, 'Times new Roman'))

@drugs.each do |drug|
  document.paragraph(styles['NORMAL']) do |p|
    p << "#{drug.name}"       
  end
end

Current display format is listed below:

drug one

drug two 

drug three

However,required display format is:

  • first drug

  • second drug

  • third drug

Ben
  • 2,314
  • 1
  • 19
  • 36
user3893686
  • 33
  • 1
  • 7
  • What is `Font`? Are you using [this ruby gem](https://github.com/dj2/Ruby-RTF)? Or maybe [this one](https://github.com/clbustos/rtf)? Can you please provide a [complete](http://stackoverflow.com/help/mcve) example, so we can properly understand the question? – Tom Lord Feb 21 '17 at 12:00
  • Thank you @tom lord i am using the [this one](https://github.com/clbustos/rtf) – user3893686 Feb 21 '17 at 14:36

1 Answers1

0

Your code is using the 'rtf' ruby gem, so my following answer is based on this.

There may be other libraries available to solve this problem, or you could even consider writing your own solution, based on the RTF specification.

Unfortunately, the README of both the original project and the official "bug fix" fork do not mention how to format bullet points with the library. (Also, neither projects have been updated in about 5 years...) The github code was originally copied from this ruby-forge project, which also does not mention bullet points.

In times like this, you unfortunately need to dig in to the actual source code to find out what's supported by the library - and sure enough, you'll find RTF::ListTable which seems to handle bullet points.

However, you will not find this in your version of the library. This github version of the gem appears to be uploaded as a different ruby gem. To use this updated version of the library, you will need the clbustos-rtf gem instead.

Community
  • 1
  • 1
Tom Lord
  • 27,404
  • 4
  • 50
  • 77
  • Thank you again and does the [clbustos-rtf](https://rubygems.org/gems/clbustos-rtf) gem supports the bullet point easily ? – user3893686 Feb 21 '17 at 14:41
  • Can you please have a go at this yourself, first? I'm not providing a free code writing service :) ... But glancing at the source code, it appears to support bullet points, which can be labelled either with a "disk", "hyphen" or "decimal". – Tom Lord Feb 21 '17 at 15:34