obsolete.ChilliProject/vendor/plugins/rfpdf
Jean-Philippe Lang 446ef61680 Korean support for PDF export (#4639).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3389 e93f8b46-1217-0410-a6f0-8f06a7374b81
2010-02-07 12:30:44 +00:00
..
lib Korean support for PDF export (#4639). 2010-02-07 12:30:44 +00:00
test trunk moved from /trunk/redmine to /trunk 2006-12-05 20:45:04 +00:00
CHANGELOG trunk moved from /trunk/redmine to /trunk 2006-12-05 20:45:04 +00:00
MIT-LICENSE trunk moved from /trunk/redmine to /trunk 2006-12-05 20:45:04 +00:00
README trunk moved from /trunk/redmine to /trunk 2006-12-05 20:45:04 +00:00
init.rb Merged Rails 2.1 compatibility branch. 2008-07-04 17:58:14 +00:00

README

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

= RFPDF Template Plugin

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

== Example .rb method Usage

In the controller, something like:

  def mypdf
		pdf = FPDF.new()

		#
		# Chinese
		#
		pdf.extend(PDF_Chinese)
		pdf.AddPage
		pdf.AddBig5Font
		pdf.SetFont('Big5','',18)
		pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %')
		icBig5 = Iconv.new('Big5', 'UTF-8')
		pdf.Write(15, icBig5.iconv("宋体 should be working"))
		send_data pdf.Output, :filename => "something.pdf", :type => "application/pdf"
  end

== Example .rfdf Usage

In the controller, something like:

  def mypdf
	  @options_for_rfpdf ||= {}
	  @options_for_rfpdf[:file_name] = "nice_looking.pdf"
  end

In the layout (make sure this is the only item in the layout):
<%= @content_for_layout %>
  
In the view (mypdf.rfpdf):

<%
	pdf = FPDF.new()
	#
	# Chinese
	#
 	pdf.extend(PDF_Chinese)
 	pdf.AddPage
 	pdf.AddBig5Font
 	pdf.SetFont('Big5','',18)
 	pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %')
 	icBig5 = Iconv.new('Big5', 'UTF-8')
 	pdf.Write(15, icBig5.iconv("宋体 should be working"))

	#
	# Japanese
	#
 	pdf.extend(PDF_Japanese)
 	pdf.AddSJISFont();
 	pdf.AddPage();
 	pdf.SetFont('SJIS','',18);
 	pdf.Write(5,'9ÉñåéÇÃåˆäJÉeÉXÉgÇåoǃPHP 3.0ÇÕ1998îN6åéÇ…åˆéÆÇ…ÉäÉäÅ[ÉXÇ≥ÇÍÇǵÇΩÅB');
 	icSJIS = Iconv.new('SJIS', 'UTF-8')
 	pdf.Write(15, icSJIS.iconv("これはテキストである should be working"))

	#
	# Korean
	#
 	pdf.extend(PDF_Korean)
 	pdf.AddUHCFont();
 	pdf.AddPage();
 	pdf.SetFont('UHC','',18);
 	pdf.Write(5,'PHP 3.0Àº 1998³â 6¿ù¿¡ °ø½ÄÀûÀ¸·Î ¸±¸®ÁîµÇ¾ú´Ù. °ø°³ÀûÀÎ Å×½ºÆ® ÀÌÈľà 9°³¿ù¸¸À̾ú´Ù.');
 	icUHC = Iconv.new('UHC', 'UTF-8')
 	pdf.Write(15, icUHC.iconv("이것은 원본 이다"))

	#
	# English
	#
 	pdf.AddPage();
	pdf.SetFont('Arial', '', 10)
	pdf.Write(5, "should be working")
%>
<%=	pdf.Output() %>
	  
	
== Configuring

You can configure Rfpdf by using an @options_for_rfpdf hash in your controllers.

Here are a few options:

:filename (default: action_name.pdf)
  Filename of PDF to generate

Note: If you're using the same settings for @options_for_rfpdf often, you might want to 
put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).

== Problems

Layouts and partials are currently not supported; just need
to wrap the PDF generation differently.