Skip to content

Epictetus/rfpdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

= RFPDF Template Plugin

A template plugin allowing the inclusion of ERB-enabled RFPDF template files.

==
==
== TCPDF Version (The New or UTF8(Embedded Font) Version)
==
==

If you are using HTML, it is recommended you install:

gem install -r htmlentities

TCPDF Documentation located at:

http://phpdocs.moodle.org/com-tecnick-tcpdf/TCPDF.html

TCPDF Example of simple use in .html.erb:

<%
  @pdf = TCPDF.new()
  @pdf.SetMargins(15, 27, 15)
  @pdf.AddPage()
  text_options = {:font => "freeserif"}
  @pdf.draw_text(15, 10, "text", {:font_size => 12, :font => "freeserif"})
%><%=@pdf.Output()%>

See the following files for sample of useage:

test_unicode.rfpdf
utf8test.txt
logo_example.png

FPDF(Non Embedded Font) users can migrate to TCPDF by changing the following from:

  pdf = FPDF.new

to:

  pdf = TCPDF.new


FPDF Example of simple use in .html.erb:
<%
  require 'rfpdf/fpdf'

  @pdf = FPDF.new

  @pdf.SetFont('Arial','', 8)

  @pdf.SetMargins(15, 27, 15)
  @pdf.AddPage()
  @pdf.Write(5, "text", '')
%><%=@pdf.Output()%>

FPDF Japanese Example of simple use in .html.erb:
<%
  require 'rfpdf/fpdf'
  require 'fpdf/japanese'

  @pdf = FPDF.new

  @pdf.extend(PDF_Japanese)
  @pdf.AddSJISFont
  @pdf.SetFont('SJIS','', 8)

  @pdf.SetMargins(15, 27, 15)
  @pdf.AddPage()
  @pdf.Write(5, "text\n", '')

  sjis_text = Iconv.new('SJIS', 'UTF-8').iconv("UTF-8 Japanese text.\n")
  @pdf.Write(5, sjis_text, '')
%><%=@pdf.Output()%>

ENJOY!

About

Ruby on Rails TCPDF plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published