Guest User

Untitled

a guest
Jun 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. # encoding: utf-8
  2. #
  3. # Generates a couple simple tables, including some UTF-8 text cells.
  4. # Although this does not show all of the options available to table,
  5. the most
  6. # common are used here. See fancy_table.rb for a more comprehensive
  7. example.
  8. #
  9. # require "#{File.dirname(__FILE__).to_s}/../example_helper.rb"
  10. require 'rubygems'
  11. require "prawn/core"
  12. require "prawn/layout"
  13.  
  14. class Create_pdf_table
  15.  
  16. def make_pdf_table (file, pdf)
  17.  
  18. # =begin
  19. Prawn::Document.generate("#{file}.pdf") do
  20. font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
  21.  
  22. # cell [0,730],
  23. :text => "'"[ + pdf[0] + ]"'",
  24. :font_size => 80,
  25. # :font_style => :bold,
  26. :border_width => 0,
  27. :text_color => 'f07878'
  28. move_down 10
  29.  
  30. table "'"[ + pdf[2] ] "'",
  31. :font_size => 18,
  32. :horizontal_padding => 10,
  33. :vertical_padding => 3,
  34. :border_width => 0,
  35. :position => :center,
  36. :headers => "'"[ + pdf[1] ]"'",
  37. :font_size => 28
  38. :font_style => :bold,
  39. :align => {1 => :left},
  40. :align_headers => :left
  41.  
  42. end
  43. end
  44. end
  45.  
  46. a = Create_pdf_table.new
  47. t = "This is a title line"
  48. h = "[=============================col a col b col
  49. c-----------------------------]"
  50.  
  51. l = "[row 1 a b][row 2 a b][row
  52. 3 a b]"
  53.  
  54. data = Array[2]
  55. data[0] = t
  56. data[1] = h
  57. data[2] = l
  58.  
  59. a.make_pdf_table 'atable',data
Add Comment
Please, Sign In to add comment