nickfrandsen / htmltoword Goto Github PK
View Code? Open in Web Editor NEWRuby html to word gem
License: MIT License
Ruby html to word gem
License: MIT License
It looks like the gem has a hard dependency on Rails
I'm getting a lot of line breaks in my document. I'm not entirely sure what's being fed into the converter. WickedPDF can enable debug mode with a URL parameter. I'd like to do the same with htmltoword. Something like this:
http://domain.com/controller/export.docx?debug=true
If I have the time, I might be able to contribute this but time is short these days.
How do I center things when exporting. Is there documentation or a way to do this and other things found in word?
I am probably missing something obvious, but I have not yet succeeded in generating a docx file with this gem.
I'm running rails 4.2.0 with ruby 2.2.0
I've added the gem to my gemfile and bundle install
I noticed that the template and xslt files were not downloaded, so I downloaded them manually and saved them the lib directory.
I've tried messing around with the configuration i orderto point to the correct lib folder - both in the gem as well as in my rails project.
The mentioned error message appears here in my controller:
def download
respond_with(@case, content: '<html><body>some html</body></html>')
end
Any help is greatly appreciated!
First - thanks for making this thing, it's a big challenge.
I'm wondering about link support.
<a href="#asdf">news</a>
That's just outputting line breaks for the opening and closing A tags.
Is possible support to insert image tag?
If I have a <br>
tag in a <p>
tag in my HTML, it is not converted into a line break in the Word-file. Is this intended behaviour? @nickfrandsen @anitsirc
This is a feature request for the ability to set a font and font size for a document, paragraph, or both.
Looking into the WordprocessingML doc, it appears you can either explicitly list the font and size on a run every time, or create a document style and apply that style to the run.
Perhaps we could apply a font-size and font-family style to the body tag and have that body style propagate to all runs under it, or apply a style to a paragraph and have the run use that paragraphs style.
Something like this appears to work:
<w:p>
<w:r>
<w:rPr>
<w:sz w:val="50"/>
<w:rFonts w:ascii="Times New Roman" />
</w:rPr>
<w:t xml:space="preserve">This paragraph is Times New Roman at 25pt</w:t>
</w:r>
</w:p>
I'm having trouble applying a fixed width to a set of div's. When viewed in the word file, it doesn't seem to be working.
`
Also, if you don't mind clarifying what this is meant to do params[:docx_html_source]
Thank you!
This is a feature request to add the ability to set line spacing on a body or paragraph level (similar to #19)
The line spacing is set on paragraph level with a line spacing of 1 set to the value 240, 1.5 is then 360, and 2 is 480.
The following paragraph property seems to work:
<w:pPr>
<w:spacing w:line="480" />
</w:pPr>
text wrapped in small, sup is not shown at all. the XSLX file doesnt seem to match such elements at all
how to insert images into header and footer
Hello Guys,
I got strange error with rubyzip:
file = Htmltoword::Document.create my_html, file_name
NameError: uninitialized constant Zip::File
from /home/..../gems/htmltoword-0.1.8/lib/htmltoword/document.rb:46:in `block in save'
Thanks for any help )
I'm added to Gemfile gem 'htmltoword', '0.2.0'
into a new rails 4.2.1 app. But than i starts a rails server an error appear.
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/htmltoword-0.2.0/lib/htmltoword/action_controller.rb:41:in `': uninitialized constant ActionController::Responder (NameError) from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/htmltoword-0.2.0/lib/htmltoword.rb:26:in `require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/htmltoword-0.2.0/lib/htmltoword.rb:26:in `' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:76:in `require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:76:in `block (2 levels) in require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:72:in `each' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:72:in `block in require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:61:in `each' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler/runtime.rb:61:in `require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.5/lib/bundler.rb:134:in `require' from /vagrant/HtmlWordConverter/config/application.rb:7:in `' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `' from bin/rails:4:in `require' from bin/rails:4:in `'
After removing gem rails server starts normally. What problem in? What versions of Ruby/Rails supported? I tried ruby versions 2.0, 2.1.5, 2.2.2 and Rails 4.2.1. Same problem persist.
I created a word document using version 1.8 of htmltoword. It was interpreted fine in Openoffice, but after trying to open with a copy of microsoft word, the software reported the file was corrupted. I upgraded to version 2.0 and copied to the xslt to where I believe was the correct place, and regenerated the document. This document could be opened in word, but alot of preserve whitespace xml nodes were added, creating undesirable formatting. Is there something im missing here? I removed everything complex in the end, and tried to just render a paragraph, but still excessive white space appeared above and below the paragraph in the produced word document. I can attempt to write another xslt, but I'm wondering if there's anything obvious that ive missed....
Hi !
I'd like to know if images can be supported by your gem. I suppose not because it didn't worked for me and I can't see any reference to images or <img>
tags in your source code (I only searched for it a bit).
If it is not supported yet, I'd be happy to try to implement it if you can guide me, since I don't know XSLT.
But I imagine some kind of HTML pre-processing to download images and reference them directly from inside the generated .docx "zip" file may do the trick - or maybe not ?
Thanks for your work though, it works nicely for the rest of the document, and a ruby solution is really appreciated here.
CircleCI, Travis, anything along those lines that can integrate with GitHub
With htmltoword version >= 0.2 there's no need to declare the mime-type, but I'm using htmltoword ver 0.5.1. I can't fix this "uninitialized constant Mime::DOCX" error. I need help.
I'm using RVM with Ruby 2.2.0 and when I try to use the gem I get path issues along the following lines:
Zip::Error (File /Users/jon/.rvm/gems/ruby-2.2.0@custom-gemset/gems/htmltoword-0.2.0/lib/htmltoword/templates/default.docx not found):
app/controllers/welcome_controller.rb:6:in `block in index'
app/controllers/welcome_controller.rb:5:in `index'
Looking in the gemset folder for the gem files shows they are not there either.
In my action when I call
respond_to do |format|
format.docx do
file = Htmltoword::Document.create params[:docx_html_source], "file_name.docx"
send_file file.path, :disposition => "attachment"
end
end
I get an error
undefined method `gsub' for nil:NilClass
on
file = Htmltoword::Document.create params[:docx_html_source], "file_name.docx"
line
I use 0.1.8 verison of htmltoword on rails 4.1.1
After I bundle install the gem, when I load the library, this is what happened:
[1] pry(main)> require 'htmltoword'
NameError: constant Logger::Format not defined
from /srv/scholar/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-1.4.0/lib/action_controller/support/clean_logger.rb:5:in `remove_const'
ruby version: 2.1.2
Is this gem still maintained? We'd love to use it for a few projects.
@anitsirc, @MadsBuus, it looks like you're maintaining a fork over in https://github.com/karnov/htmltoword, with some great improvements, but have issues disabled?
Edit: The reason I ask, is that I'd also like to contribute. ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.