[ACCEPTED]-Set the font color in prawn-prawn
Accepted answer
Have you tried fill_color
? Code below should work:
require "rubygems"
require "prawn"
Prawn::Document.generate "hello.pdf" do
fill_color "0000ff"
text "Hello World (in blue)", :at => [200,720], :size => 32
end
0
if you use any 1.x version (it's only a 2 pre-release as of writing) you can also 1 use:
Gem install:
$ gem install prawn --pre
Code:
require "rubygems"
require "prawn"
Prawn::Document.generate "hello.pdf" do
text "Hello World (in blue)", :color => "0000ff", :size => 32
end
Note that you can also set a CMYK color 1 (in this example 100% key black):
fill_color(0,0,0,100)
Use the color
option
text "Red color here", color: 'FF0000'
And the result:
With the utmost respect, there 5 is no need to use fill_color
as of 2022 because you 4 have to manually set and then unset the 3 color - IMO it's much better to set the 2 color directly via the prawn DSL (domain 1 specific language).
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.