Paste content from an MS Word document and retain formatting

5 views
Skip to first unread message

Dennis Bulgatz

unread,
Mar 15, 2023, 12:22:02 AM3/15/23
to ActiveScaffold : Ruby on Rails Gem
Hello,

Very grateful for all the support from Sergio, but this is not intended as a question for just him, but rather for other devs in the community.  So, hoping others will reply.

The capability to paste content from an MS Word document and keep the basic formatting must be a fairly common need.  But The only solutions I see are
  •  Not using a Rich Text editor (works but generally poor form)
  •  Using TinyMCE, and then having a custom/paid plugin like PowerPaste.

The PowerPaste provides seems nice.  But beyond the cost, pasting in content from a contract requires that the paragraph numbering not be lost or changed, and PowerPaste does not handle this.  Or, at least it does not seem to.

Also, I could not find any documentation on how to use the PowerPaste cloud-based solution in a rails site that uses the gem 'tinymce-rails'.  

Thanks for any help/thoughts/suggestions.

Dennis




Dennis Bulgatz

unread,
Mar 23, 2023, 12:00:32 PM3/23/23
to ActiveScaffold : Ruby on Rails Gem
In case anyone else is interested.  I gave up on PowerPaste.. expensive and seems a challenge to try out.  I ended up writing a custom parser to read word documents directly, using the yomu2 gem.  Yomu will read a word file into HTML.  Then, used Nokociri to parse the HTML.

io = StringIO.new(self.document_file)
yomu = Yomu.new io
document_content = yomu.text

document = Nokogiri::HTML5(yomu.html)
Reply all
Reply to author
Forward
0 new messages