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::F ......
FPDFÄÜÖ§³ÖPDFµÄÖÐÎÄ´òÓ¡£¬È»¶øÈ´´æÔÚ²»ÉٵIJ»ÈçÒâÖ®´¦£¬¾ÝÎÒÄ¿Ç°µÄʹÓã¬×ܽá³ö¼¸µã£º
1£©FPDFÌṩµÄPdf_Chinese×ÖÌ壬½«GBÕâÖÖ×ÖÌåдÈëÁË´úÂëÖУ¬ÈôÎÒÃÇÏ£ÍûÒýÈëÆäËûµÄÖÐÎÄ×ÖÌ壬Ôò²»ÄÜ·½±ãµØʹÓÃ
2£©FPDFÊä³öµÄÊý×Ö²¢²»ÃÀ¹Û£¬²»ÈçRuport::Formatter::PDF×Ô´øµÄ×ÖÌå
3£©FPDFÌṩµÄ·½·¨²¢²»¶à£¬¶ÔÓÚÒ»°ãµÄ±¨±í´òÓ¡£¬ÓõÄ×î¶àµÄÒ²ÐíÊÇ Cell·½·¨£¬µ«Èç¹ûÁ¬Ò»¸öÆÕͨµÄ±¨±í´òÓ¡¶¼ÐèÒªÄܹý´úÂë¿ØÖÆ»»ÐС¢»Ö±Ïß¡¢Ð´µ¥Ôª¸ñ£¬ÄǾÍÌ«²»·½±ãÁË
PrawnÒ²ÊǺôÉù½Ð¸ßµÄÒ»ÖÖRuby PDF±¨±í¹¤¾ß£¬¶ÔÓÚËüºÍ FPDF µ½µ×˸üÓÅÐ㣬Õâ¾ÍÒªÒòÈ˶øÒìÁË£¬FPDFÊÇÓÃPHP±àдµÄPDF¿âµÄÒÆÖ²£¬¶øPRAWNÔò²»ÊÇ Prawn£ºÊ¹ÓÃRubyÉú³ÉPDF¸ü¼ò½Ý ÖÐÓмòµ¥µÄ½éÉÜ
ÏÂÃæÀ´¿´¿´PRAWNÊÇÈçºÎʵÏÖPDFµÄ´òÓ¡µÄ£¨»ù±¾µÄʵÏֲο¼ Ruby Ruportʵ¼ù—¼òµ¥±¨±íϵͳ£©
Ò»¡¢°²×°Prawn
gem install prawn
¶þ¡¢ÐÞ¸Äenviroment.rb
Ìí¼ÓÈçÏÂÒýÓãº
require "prawn"
require 'prawn/layout'
Èý¡¢ÒýÈëºÏÊʵÄÖÐÎÄ×ÖÌå
PrawnÖ§³ÖÍⲿÒýÈëÖÐÎÄ×ÖÌ壬ÀýÈç“¿¬Ìå”
´ÓC:\Windows\FontsϽ«±¾»úÖ§³ÖµÄ×ÖÌåÎļþ(*.ttf)¸´ÖƵ½
%RUBY_HOME%\lib\ruby\gems\1.8\gems\prawn-core-0.8.4\data\fonts
ÔÚ´úÂë ......
ת×Ô51testing.com, Ô¼û£ºhttp://bbs.51testing.com/thread-171535-1-1.html http://swik.net/Watir+Programming
http://www.pragprog.com/ #ºÜ¶àºÃµÄÔ´ÂëŶ
http://docs.rubygems.org/ #rubygems
http://www.fxruby.org/ #fxruby
http://groups.google.com/group/watir-general/topics #google watirÌÖÂÛ×é
http://ruby.nanshapo.com/weeks/2007-29.html
http://www.gotapi.com/rubyrails #API±È½ÏÈ«
http://www.ruby-forum.com/forum/4 #rubyµÄÂÛ̳
http://navigation-china.com/ExcelVBA/Main.htm #excelµÄAPIº¯Êý
http://members.shaw.ca/paul_rogers/watir_tests/ #Á·Ï°³¡Ëù
http://www.kuqin.com/rubycndocument/man/index.html #ruby²Î¿¼ÊÖ²á
http://www.ruby-doc.org/core/ #ruby API
http://wtr.rubyforge.org/rdoc/ #watirµÄapi
http://wiki.openqa.org/display/WTR/Project+Home #watir½Ì³Ì
http://www.w3school.com.cn/
http://www.rubyidea.com/bbs/
http://okruby.com/ #Óкܶà½Ì³Ì
http://www.docin.com/app/searchnew/fpg?keyword=ruby #ºÜ¶àÔÚÏ ......
Installing Ruby from source is my preferred method, although in Ubuntu Feisty you can supposedly install it with apt-get install ruby
now. Here’s the essential packages needed to get a source build working right though and the process I just went through:
sudo apt-get install build-essential
sudo apt-get install libreadline-dev
sudo apt-get install libz-dev (this is necessary for RubyGems to install - amongst other things)
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar xzvf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure
make
make install
And to install RubyGems..
wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar xzvf rubygems-0.9.2.tgz
cd rubygems-0.9.2
ruby setup.rb
......
Update: This post is outdated. All in one installer for 1.9
is ready now, you should use it if you need 1.9 on windows. Get it here
http://rubyforge.org/frs/?group_id=167
Ruby has “all-in-one” installer for Windows, but it is outdated. As
of May 2009, Ruby 1.9.1 is released, the installer is still 1.8.6. If
you want the latest version, you need the zip package. But the zip
package is missing zlib.dll, libeay32.dll, ssleay32.dll and readline.dll
. Here is how to install it on windows.
Download the file
First you download the 1.9 package from http://www.ruby-lang.org/en/downloads/
Choose “Ruby 1.9 xxx binary” instead of “Ruby xxx Installer”.
Install it
Just Unpack the zip to c:\ruby.
Then add c:\ruby\bin to windows PATH.
Open a windows command console and type
gem update --system
Oops, it is broken! The binary is missing some dll files.
Let us fix it
zlib
Download zlib windows binary from
http://gnuwin32.sourceforge.net/ ......
RubyÓïÑÔѧϰϵÁÐ--»ù±¾µÄrubyÓï·¨
1. »ù±¾µÄrubyÓï·¨
1.1 ±äÁ¿¡¢³£Á¿ºÍÀàÐÍ
1) ¶¨Òå±äÁ¿
±äÁ¿ÀàÐÍ
ÃèÊö
ʾÀý
¾Ö²¿±äÁ¿£¨»òα±äÁ¿£©
ÒÔСд×Öĸ»òÏ»®Ïß¿¨Í·
var _var
È«¾Ö±äÁ¿
ÒÔ$¿ªÍ·
$var
Àà±äÁ¿
ÀàÖж¨Ò壬ÒÔ@@¿ªÍ·
@@var
ʵÀý±äÁ¿
¶ÔÏóÖж¨Ò壬ÒÔ@¿ªÍ·
@var
³£Á¿
ÒÔ´óд×Öĸ¿ªÍ·
Var
2) ±äÁ¿ÄÚ²å
ÔÚË«ÒýºÅÄÚʹÓÓ#{±äÁ¿Ãû}”ÄÚ²å±äÁ¿
a = 2
b = 3
puts "#{a} + #{b} = #{a+b}" #ÊäÈë½á¹ûΪ£º2 + 3 = 5
1.2 ×¢ÊÍ
1£©µ¥ÐÐ×¢ÊÍ£ºÒÔ#¿ªÍ·£¬È磺 #×¢ÊÍÄÚÈÝ
2£©¶àÐÐ×¢ÊÍ£ºÔÚ=begin ºÍ =end Ö®¼ä¶¨Ò壬È磺
=begin
×¢ÊÍÄÚÈÝ
=end
1.3 Ñ»·ºÍ·ÖÖ§
1.3.1 Ìõ¼þÓï¾ä
If ÐÎʽ
unless ÐÎʽ
a =1 if y==3
a=1 unless y!=3
x= if a > 0 then b else c end
x= unless a<=0 then a else b end
if x<5 then
a =1
else
a =2
end
unles ......
×ܼǼÊý:146; ×ÜÒ³Êý:25; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [1] 2
[3] [4] [5] [6] [7] [8] [9] [10] ÏÂÒ»Ò³ βҳ