开发者

Can we create an Image by HTML string in Ruby On Rails.

I would like to know , Is there any possibility by which 开发者_如何学JAVAwe can create an image by the HTML sting that has the HTML tags along with the formatting Or the HTML content coming from the Web Editors like Ckeditor or TinyMce etc in Ruby on Rails.

Thanks Nishant


Are you referring to achieving:

<%= "<img src='http://domain.tld/some_image.png' />".html_safe %>

You can also interpolate any strings by doing

<%= "#{url_string}".html_safe %>

where url_string = "<img src='http://domain.tld/some_image.png' width='200px'/>"


I guess you want something like following

<% str = "<img src='/images/InboundButtons.png' style='border: medium none ; padding: 0px 0px 0px -2px;'>"%>
<%= str %>

Where str is an html string and you can show it as above.


It seems that your ultimate destination is a PDF file. I would skip image creation, and go right to that, using one of several HTML to PDF libraries available, perhaps one of the ones listed right here on StackOverflow. If you do need an image for some reason, even then, I would consider generating a PDF of your HTML, and then converting that to an image, since it's the best path I know to get from HTML to an image.

However, you have done a poor job of describing your problem, so with more details there might be some obvious alternative as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜