0
이 코드를 사용하여 RTF 문서를 만들었지 만 텍스트 색상을 지정하는 방법을 찾을 수 없습니다. 누군가 나를 도울 수 있습니까?Ruby RTF gem의 텍스트 RTF 색상
# encoding: utf-8
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
require 'rtf'
include RTF
colour = Colour.new(150, 150, 150)
style = CharacterStyle.new
style.bold = true
style.font_size = 28
style.foreground = colour
document = RTF::Document.new(RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman'))
document.paragraph(style) do |p|
p << "And there you have it."
end
File.open('my_document.rtf', 'w') {|file| file.write(document.to_rtf)}
은 RDoc의 마지막 예를
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rtf-0.3.3/lib/rtf/style.rb:124:in `prefix': undefined method `index' for nil:NilClass (NoMethodError)
, 많은 감사 저스틴 – peter