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
Ïà¹ØÎĵµ£º
ǰÑÔ
ÔÚ¡¶RoutingµÄÔØÈë¡·ÖУ¬ÎÒ´óÖ½éÉÜÁËÒ»ÏÂRailsÖÐ×î¼òµ¥µÄrouteÊÇÈçºÎ¼ÓÔØµÄ¡£ÕâÆªÎÄÕ£¬ÎÒ½«À´½²Ò»½²RailsϵͳÖиüΪ¸´ÔÓµÄnamed routeºÍÓëRESTfulÏà¹ØµÄresourceÊÇÈçºÎ±»¼ÓÔØµÄ¡£ÎªÁ˲»Öظ´Ì«¶àµÄ±ÊÄ«£¬ÕâÆªÎÄÕ½«ÔÚǰÎĵĻù´¡ÉϽøÐУ¬Èç¹û·¢ÏÖµ¥¶À¿´´ËÎÄʱ£¬ÓÐÉÙÐíÔÆÀïÎíÀ½¨ÒéÏÈ¿´Ò»¿´ÎÒµÄǰƪÎÄÕ£ºR ......
ÏÈ·ÅÉÏÒ»¸öʵÀýµÄbatÎļþ,ÒªÇó¹ÜÀíÔ±ÌØÈ¨ÔËÐÐ:
@echo off
::CMDÀïÏÔʾ²ÊÉ«ÎÄ×Ö
chcp 437>nul&&graftabl 936>nul
if not exist CONFIG.NT copy %WinDir%\System32\CONFIG.NT CONFIG.NT
@cls
echo DEVICE=%WinDir%\System32\ANSI.SYS /x >%WinDir%\System32\CONFIG.NT
@echo.
command /cecho
com ......
http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......
¿ª·¢»·¾³
OS:WindowsXP
Ruby:Ruby1.8.7
Rails:Rails2.3.5
Mysql:Mysql5.0.9
IDE:Rubymine2.0.1
×¼±¸¹¤×÷£º
°²×°ÒÔÏÂgem°ü
gem install ruport
gem install ruport-util
gem install acts_as_reportable
±¾ÀýÉè¼ÆµÄ±¨±íϵͳ¹¤×÷ÔÀíÈçͼ£¨´¿Êô¸öÈËÀí½â£©£¬ÒÔProducts±íΪÀý£º
½ÓÏÂÀ´ÊµÏÖµÄÀý×Ó½«ÀûÓÃeval·½·¨ÊµÏ ......