Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ruby Ruportʵ¼ù—ÖÐÎÄPDF±¨±íÖ®FPDF

RuportÖÐpdf_writer¶ÔÖÐÎĵÄÖ§³Ö²¢²»ºÃ£¬Êä³öµÄÖÐÎÄÏÔʾµÄÊÇÂÒÂë¡£ÉÏÍø²éÁ˺ܶà×ÊÁÏ£¬Ò²Ã»ÓÐÕÒµ½ºÃµÄ½â¾ö·½°¸£¬ÎÞÄÎÖ»ºÃ²é¿´Ô´´úÂ룬µ½µ×ΪʲôRuport×Ô´øµÄPDF¹¤¾ß²»Ö§³ÖÖÐÎÄÊä³ö¡£
Ruport::Formatter::PDF::WriterÖÐÕÒµ½ÒÔÏ´úÂë
   metrics = load_font_metrics(font)
   metrics = PDF::Writer::FontMetrics.open(font)
   PDF::Writer::FontMetrics::METRICS_PATH = [ File.join(File.dirname(File.expand_path(__FILE__)), 'fonts') ]
Ô­À´METRICS_PATH=%RUBY_HOME%\lib\ruby\gems\1.8\gems\pdf-writer-1.1.8\lib\pdf\writer\fonts
ÔÚ´Ë·¾¶Ï´æÔÚµÄafm×ÖÌåÎļþ¾ù²»Ö§³ÖÖÐÎÄ£¬ÓÚÊÇ¿ªÊ¼½«Ä¿±êתÏòÌí¼ÓÒ»¸öÖ§³ÖÖÐÎÄµÄ *.afm×ÖÌåÎļþ¡£ÎÞÄÎÎļþÕÒµ½ÁË£¬·Åµ½¸Ã·¾¶Ï£¬ÔËÐо¹±¨´íÁË£¨Ò²ÐíÊÇPDF_WRITER²»Ö§³Ö¸ÃÎļþ£©
·ÅÆúÁË´Ë·½·¨£¬°ÑÄ¿±êתÏòFPDF
1£©ÏÂÔØfpdf http://download.csdn.net/source/5608
2£©½âѹµ½RailsÏîÄ¿µÄlibÏÂ
3£©°´Ruby Roportʵ¼ù—¼òµ¥±¨±íϵͳÍê³ÉRuportÓ¦ÓÃ
4£©½ÓÏÂÀ´£¬ÐÞ¸ÄReportOutputController.rb
½« class Ruport::Formatter::PDFÐÞ¸ÄΪÈçÏÂÄÚÈÝ
class Ruport::Formatter::FPDF < Ruport::Formatter::PDF
def pdf_writer
unless @pdf_writer
@pdf_writer = ::FPDF.new
@pdf_writer.extend(PDF_Chinese)
@pdf_writer.AddPage
@pdf_writer.AddGBFont
@pdf_writer.SetFont('GB','', options[:font_size] || 16)
end
return @pdf_writer
end
def render_pdf
output << pdf_writer.Output
end
end
class Pdf < Ruport::Formatter::FPDF
renders :pdf, :for => BaseSqlController
build :data_sheet do
eval(options[:pdfContent])
end
end
5£©ÐÞ¸ÄÊý¾Ý±íreport_templatesÖÐtemplate_contentÄÚÈÝΪ
pdf_writer.SetFont('GB','B',10)
pdf_writer.SetLeftMargin(80)
pdf_writer.Cell(40,10,Iconv.conv('GB2312','UTF-8','²úÆ·±¨±í2'))
pdf_writer.Ln()
pdf_writer.SetFont('GB','',8)
pdf_writer.Cell(40,5,Iconv.conv('GB2312','UTF-8','Ãû³Æ'),1,0,'C')
pdf_writer.Cell(40,5,Iconv.conv('GB2312','UTF-8','Àà±ð'),1,0,'C')
pdf_writer.Cell(40,5,Iconv.conv('GB2312','UTF-8','¼Û¸ñ'),1,0,'C')
pdf_wri


Ïà¹ØÎĵµ£º

Ruby¼Ì³Ð ¾ÅͲһÌõ

Ruby ÀàµÄ¼Ì³Ð
¹Ø¼ü×Ö: Ruby ÀàµÄ¼Ì³Ð


Ò»¡¢ÆÕͨ·½Ê½µÄ¼Ì³Ð
 RubyÖ»Ö§³Öµ¥¼Ì³Ð
 
ruby ´úÂë
class
 Child < Father
  

......   

end
  

    ObjectÊÇËùÓÐÀàµÄÊ¼×æ£¬²¢ÇÒObjectµÄʵÀý·½·¨ ......

RUBYʵ¼ù—´øÃÜÂë¼ÓÃܵÄÓû§´´½¨¼°ÐÞ¸Ä

¿ª·¢»·¾³
Ruby: Ruby1.9.1
Rails: Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨Êý¾Ý±íUsers
ÀûÓÃRubyMine×Ô´øµÄScaffold¹¤¾ß´´½¨Êý¾Ý±íUsers£¬Ò²¿ÉÒÔÊÖ¶¯´´½¨
¶þ¡¢´´½¨ControllerºÍView
RubyÏîÄ¿—>ÓÒ¼ü—>Create Model
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎ ......

RubyϽâ¾öoci8°²×°´íÎóµÄÎÊÌâ

Prepare
1. Download 'OCI 1.x.x.rb' (it's VERY important - execution MUST be *.rb)
2. Download 'oci8lib.so'
Install
1. Copy 'OCI8.rb' to .../ruby/lib/ruby/site_ruby/1.8/DBD/OCI8
2. Copy 'oci8.rb' to .../ruby/lib/ruby/site_ruby/1.8
3. Copy 'oci8lib.so' to .../ruby/lib/ruby/site_ruby/1.8/i386-msv ......

¼Ç¼ÏÂ×Ô¼ºUbunt 10.04 ´î½¨ruby on rails»·¾³

1¡¢°²×°ubuntu
һ·next£¬¼Çס°²×°Ó¢Îİ档´ý°²×°Íê±Ïºó£¬Ê×ÏÈÑ¡Ôñ“Èí¼þÔ´”£¬ÏµÍ³--ϵͳ¹ÜÀí-Èí¼þÔ´£¬¹úÄÚÒ»°ãÑ¡ÔñµÄÊÇ£ºhttp://ubuntu.cn99.com/ubuntu;½Ó×Ű²×°ÖÐÎİü£¬Ñ¡ÔñÈí¼þÔ´¾ÍÊÇΪÁËÏÂÔØÈí¼þµÄËٶȸü¿ì£¬°²×°Íê³ÉºóÖØÆôubuntu£¬ÖØÆôºó»áÌáʾÊÇ·ñ¸Ä±äijЩÎļþ¼ÐÃû³Æ£¬Ñ¡Ôñ“·ñ”£¬·Àֹϵͳ¶Ô ......

install ruby on cygwin

ת×Ô http://zhujg.javaeye.com/blog/355040
Ê×ÏÈ °²×° cygwin
cygwin Òª°²×°µÄ²å¼þÊÇ
ĬÈϵÄ+ make + gcc + libiconv
+ openssl
cygwinÏÂÐèÒª±àÒëÔ­Îļþ
µ½ruby-lang(http://ruby-lang.org/)
ÏÂÔØruby-1.9.1-p0.tar.gz
tar xvf ruby-1.9.1-p0.tar.gz
cd
ruby-1.9.1-p0
./configure
make && make in ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ