Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the font color in prawn

Im using prawn to generate a PDF output in a rails app. How do i change the color of the outputted text?

like image 310
Arcath Avatar asked Jan 07 '10 10:01

Arcath


2 Answers

if you use any 1.x version (it's only a pre-release as of writing) you can also 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
like image 31
SztupY Avatar answered Oct 15 '22 10:10

SztupY


Have you tried fill_color? Code below should work:

require "rubygems"
require "prawn" 

Prawn::Document.generate "hello.pdf" do 
  fill_color "0000ff" 
  text_box "Hello World (in blue)", :at => [200,720], :size => 32 
end
like image 164
miku Avatar answered Oct 15 '22 11:10

miku