planio-gmbh / html2odt Goto Github PK
View Code? Open in Web Editor NEWhtml2odt generates ODT documents based on HTML fragments
License: MIT License
html2odt generates ODT documents based on HTML fragments
License: MIT License
If i run it, this error apperas:
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in require': /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/lib/html2odt/document.rb:17: syntax error, unexpected tLABEL, expecting ')' (SyntaxError) def initialize(template: Html2Odt::ODT_TEMPLATE, html: nil) ^ /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/lib/html2odt/document.rb:17: dynamic constant assignment def initialize(template: Html2Odt::ODT_TEMPLATE, html: nil) ^ /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/lib/html2odt/document.rb:17: syntax error, unexpected tLABEL, expecting '=' def initialize(template: Html2Odt::ODT_TEMPLATE, html: nil) ^ /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/lib/html2odt/document.rb:423: syntax error, unexpected keyword_end, expecting $end from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in
require'
from /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/lib/html2odt.rb:16:in <top (required)>' from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in
require'
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/local/rvm/gems/ruby-1.9.3-p551/gems/html2odt-0.3.3/bin/html2odt.rb:4:in
<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p551/bin/html2odt.rb:23:in load' from /usr/local/rvm/gems/ruby-1.9.3-p551/bin/html2odt.rb:23:in
eval' from /usr/local/rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in
'
Is there any solution for that?
running html2odt.rb in mac-os terminal works fine :
$ html2odt.rb -i input.html -o output.odt
Wrote document to: output.odt
when I run it in a rails controller I get the encoding error
doc = Html2Odt::Document.new
doc.html= @content_page.content
doc.write_to "#{ @content_page.title}.odt"
changing the File.write mode in the gems document.rb to wb solves the error :
def write_to(path)
File.write(path, data, mode: "wb" )
end
Is there another way to solve this?
The images uploaded to active storage have an url containing a redirect :
"/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBNQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--9f786814030d4f67f566db1f3e05d3d1beb1f7d8/zot.jpeg"
This can be solved with the following change in document.rb to get the url :
def uri_to_file(uri)
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
resp = http.get(uri)
if resp.is_a?(Net::HTTPRedirection)
redirect_uri = URI.parse(resp['location'])
resp= http.get(redirect_uri)
end
return nil unless resp.is_a?(Net::HTTPSuccess)
file = Tempfile.new("html2odt")
file.binmode
file.write(resp.body)
file.flush
file
end
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.