You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issues_pdf_helper.rb 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. module Redmine
  19. module Export
  20. module PDF
  21. module IssuesPdfHelper
  22. include ActionView::Helpers::NumberHelper
  23. # Returns a PDF string of a single issue
  24. def issue_to_pdf(issue, assoc={})
  25. pdf = ITCPDF.new(current_language)
  26. pdf.set_title("#{issue.project} - #{issue.tracker} ##{issue.id}")
  27. pdf.alias_nb_pages
  28. pdf.footer_date = format_date(User.current.today)
  29. pdf.add_page
  30. pdf.SetFontStyle('B', 11)
  31. buf = "#{issue.project} - #{issue.tracker} ##{issue.id}"
  32. pdf.RDMMultiCell(190, 5, buf)
  33. pdf.SetFontStyle('', 8)
  34. base_x = pdf.get_x
  35. i = 1
  36. issue.ancestors.visible.each do |ancestor|
  37. pdf.set_x(base_x + i)
  38. buf = "#{ancestor.tracker} # #{ancestor.id} (#{ancestor.status.to_s}): #{ancestor.subject}"
  39. pdf.RDMMultiCell(190 - i, 5, buf)
  40. i += 1 if i < 35
  41. end
  42. pdf.SetFontStyle('B', 11)
  43. pdf.RDMMultiCell(190 - i, 5, issue.subject.to_s)
  44. pdf.SetFontStyle('', 8)
  45. pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}")
  46. pdf.ln
  47. left = []
  48. left << [l(:field_status), issue.status]
  49. left << [l(:field_priority), issue.priority]
  50. left << [l(:field_assigned_to), issue.assigned_to] unless issue.disabled_core_fields.include?('assigned_to_id')
  51. left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_id')
  52. left << [l(:field_fixed_version), issue.fixed_version] unless issue.disabled_core_fields.include?('fixed_version_id')
  53. right = []
  54. right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
  55. right << [l(:field_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date')
  56. right << [l(:field_done_ratio), "#{issue.done_ratio}%"] unless issue.disabled_core_fields.include?('done_ratio')
  57. right << [l(:field_estimated_hours), l_hours(issue.estimated_hours)] unless issue.disabled_core_fields.include?('estimated_hours')
  58. right << [l(:label_spent_time), l_hours(issue.total_spent_hours)] if User.current.allowed_to?(:view_time_entries, issue.project)
  59. rows = [left.size, right.size].max
  60. left << nil while left.size < rows
  61. right << nil while right.size < rows
  62. custom_field_values = issue.visible_custom_field_values.reject {|value| value.custom_field.full_width_layout?}
  63. half = (custom_field_values.size / 2.0).ceil
  64. custom_field_values.each_with_index do |custom_value, i|
  65. (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
  66. end
  67. if pdf.get_rtl
  68. border_first_top = 'RT'
  69. border_last_top = 'LT'
  70. border_first = 'R'
  71. border_last = 'L'
  72. else
  73. border_first_top = 'LT'
  74. border_last_top = 'RT'
  75. border_first = 'L'
  76. border_last = 'R'
  77. end
  78. rows = [left.size, right.size].max
  79. rows.times do |i|
  80. heights = []
  81. pdf.SetFontStyle('B', 9)
  82. item = left[i]
  83. heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
  84. item = right[i]
  85. heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
  86. pdf.SetFontStyle('', 9)
  87. item = left[i]
  88. heights << pdf.get_string_height(60, item ? item.last.to_s : "")
  89. item = right[i]
  90. heights << pdf.get_string_height(60, item ? item.last.to_s : "")
  91. height = heights.max
  92. item = left[i]
  93. pdf.SetFontStyle('B', 9)
  94. pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "",
  95. (i == 0 ? border_first_top : border_first), '', 0, 0)
  96. pdf.SetFontStyle('', 9)
  97. pdf.RDMMultiCell(60, height, item ? item.last.to_s : "",
  98. (i == 0 ? border_last_top : border_last), '', 0, 0)
  99. item = right[i]
  100. pdf.SetFontStyle('B', 9)
  101. pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "",
  102. (i == 0 ? border_first_top : border_first), '', 0, 0)
  103. pdf.SetFontStyle('', 9)
  104. pdf.RDMMultiCell(60, height, item ? item.last.to_s : "",
  105. (i == 0 ? border_last_top : border_last), '', 0, 2)
  106. pdf.set_x(base_x)
  107. end
  108. pdf.SetFontStyle('B', 9)
  109. pdf.RDMCell(35 + 155, 5, l(:field_description), "LRT", 1)
  110. pdf.SetFontStyle('', 9)
  111. # Set resize image scale
  112. pdf.set_image_scale(1.6)
  113. text = pdf_format_text(issue, :description)
  114. pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
  115. custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
  116. custom_field_values.each do |value|
  117. is_html = value.custom_field.full_text_formatting?
  118. text = show_value(value, is_html)
  119. next if text.blank?
  120. pdf.SetFontStyle('B', 9)
  121. pdf.RDMCell(35+155, 5, value.custom_field.name, "LRT", 1)
  122. pdf.SetFontStyle('', 9)
  123. if is_html
  124. pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
  125. else
  126. pdf.RDMwriteHTMLCell(35+155, 5, '', '', text, issue.attachments, "LRB")
  127. end
  128. end
  129. unless issue.leaf?
  130. truncate_length = (!is_cjk? ? 90 : 65)
  131. pdf.SetFontStyle('B', 9)
  132. pdf.RDMCell(35+155, 5, l(:label_subtask_plural) + ":", "LTR")
  133. pdf.ln
  134. issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
  135. buf = "#{child.tracker} # #{child.id}: #{child.subject}".
  136. truncate(truncate_length)
  137. level = 10 if level >= 10
  138. pdf.SetFontStyle('', 8)
  139. pdf.RDMCell(35 + 135, 5, (level >=1 ? " " * level : "") + buf, border_first)
  140. pdf.SetFontStyle('B', 8)
  141. pdf.RDMCell(20, 5, child.status.to_s, border_last)
  142. pdf.ln
  143. end
  144. end
  145. relations = issue.relations.select {|r| r.other_issue(issue).visible?}
  146. unless relations.empty?
  147. truncate_length = (!is_cjk? ? 80 : 60)
  148. pdf.SetFontStyle('B', 9)
  149. pdf.RDMCell(35 + 155, 5, l(:label_related_issues) + ":", "LTR")
  150. pdf.ln
  151. relations.each do |relation|
  152. buf = relation.to_s(issue) do |other|
  153. text = ""
  154. if Setting.cross_project_issue_relations?
  155. text += "#{relation.other_issue(issue).project} - "
  156. end
  157. text += "#{other.tracker} ##{other.id}: #{other.subject}"
  158. text
  159. end
  160. buf = buf.truncate(truncate_length)
  161. pdf.SetFontStyle('', 8)
  162. pdf.RDMCell(35+155-60, 5, buf, border_first)
  163. pdf.SetFontStyle('B', 8)
  164. pdf.RDMCell(20, 5, relation.other_issue(issue).status.to_s, "")
  165. pdf.RDMCell(20, 5, format_date(relation.other_issue(issue).start_date), "")
  166. pdf.RDMCell(20, 5, format_date(relation.other_issue(issue).due_date), border_last)
  167. pdf.ln
  168. end
  169. end
  170. pdf.RDMCell(190, 5, "", "T")
  171. pdf.ln
  172. if issue.changesets.any? &&
  173. User.current.allowed_to?(:view_changesets, issue.project)
  174. pdf.SetFontStyle('B', 9)
  175. pdf.RDMCell(190, 5, l(:label_associated_revisions), "B")
  176. pdf.ln
  177. issue.changesets.each do |changeset|
  178. pdf.SetFontStyle('B', 8)
  179. csstr = "#{l(:label_revision)} #{changeset.format_identifier} - "
  180. csstr += format_time(changeset.committed_on) + " - " + changeset.author.to_s
  181. pdf.RDMCell(190, 5, csstr)
  182. pdf.ln
  183. unless changeset.comments.blank?
  184. pdf.SetFontStyle('', 8)
  185. pdf.RDMwriteHTMLCell(
  186. 190, 5, '', '',
  187. changeset.comments.to_s, issue.attachments, ""
  188. )
  189. end
  190. pdf.ln
  191. end
  192. end
  193. if assoc[:journals].present?
  194. pdf.SetFontStyle('B', 9)
  195. pdf.RDMCell(190, 5, l(:label_history), "B")
  196. pdf.ln
  197. assoc[:journals].each do |journal|
  198. pdf.SetFontStyle('B', 8)
  199. title = "##{journal.indice} - #{format_time(journal.created_on)} - #{journal.user}"
  200. title += " (#{l(:field_private_notes)})" if journal.private_notes?
  201. pdf.RDMCell(190, 5, title)
  202. pdf.ln
  203. pdf.SetFontStyle('I', 8)
  204. details_to_strings(journal.visible_details, true).each do |string|
  205. pdf.RDMMultiCell(190, 5, "- " + string)
  206. end
  207. if journal.notes?
  208. pdf.ln unless journal.details.empty?
  209. pdf.SetFontStyle('', 8)
  210. text = pdf_format_text(journal, :notes)
  211. pdf.RDMwriteFormattedCell(190, 5, '', '', text, issue.attachments, "")
  212. end
  213. pdf.ln
  214. end
  215. end
  216. if issue.attachments.any?
  217. pdf.SetFontStyle('B', 9)
  218. pdf.RDMCell(190, 5, l(:label_attachment_plural), "B")
  219. pdf.ln
  220. issue.attachments.each do |attachment|
  221. pdf.SetFontStyle('', 8)
  222. pdf.RDMCell(80, 5, attachment.filename)
  223. pdf.RDMCell(20, 5, number_to_human_size(attachment.filesize), 0, 0, "R")
  224. pdf.RDMCell(25, 5, format_date(attachment.created_on), 0, 0, "R")
  225. pdf.RDMCell(65, 5, attachment.author.name, 0, 0, "R")
  226. pdf.ln
  227. end
  228. end
  229. pdf.output
  230. end
  231. # Returns a PDF string of a list of issues
  232. def issues_to_pdf(issues, project, query)
  233. pdf = ITCPDF.new(current_language, "L")
  234. title = query.new_record? ? l(:label_issue_plural) : query.name
  235. title = "#{project} - #{title}" if project
  236. pdf.set_title(title)
  237. pdf.alias_nb_pages
  238. pdf.footer_date = format_date(User.current.today)
  239. pdf.set_auto_page_break(false)
  240. pdf.add_page("L")
  241. # Landscape A4 = 210 x 297 mm
  242. page_height = pdf.get_page_height # 210
  243. page_width = pdf.get_page_width # 297
  244. left_margin = pdf.get_original_margins['left'] # 10
  245. right_margin = pdf.get_original_margins['right'] # 10
  246. bottom_margin = pdf.get_footer_margin
  247. row_height = 4
  248. # column widths
  249. table_width = page_width - right_margin - left_margin
  250. col_width = []
  251. unless query.inline_columns.empty?
  252. col_width = calc_col_width(issues, query, table_width, pdf)
  253. table_width = col_width.sum
  254. end
  255. # use full width if the query has block columns (description, last_notes or full width custom fieds)
  256. if table_width > 0 && query.block_columns.any?
  257. col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
  258. table_width = col_width.sum
  259. end
  260. # title
  261. pdf.SetFontStyle('B', 11)
  262. pdf.RDMCell(190, 8, title)
  263. pdf.ln
  264. # totals
  265. totals = query.totals.map {|column, total| "#{column.caption}: #{total}"}
  266. if totals.present?
  267. pdf.SetFontStyle('B', 10)
  268. pdf.RDMCell(table_width, 6, totals.join(" "), 0, 1, 'R')
  269. end
  270. totals_by_group = query.totals_by_group
  271. render_table_header(pdf, query, col_width, row_height, table_width)
  272. previous_group = false
  273. result_count_by_group = query.result_count_by_group
  274. issue_list(issues) do |issue, level|
  275. if query.grouped? &&
  276. (group = query.group_by_column.group_value(issue)) != previous_group
  277. pdf.SetFontStyle('B', 10)
  278. group_label = group.blank? ? +'None' : group.to_s.dup
  279. group_label << " (#{result_count_by_group[group]})"
  280. pdf.bookmark group_label, 0, -1
  281. pdf.RDMCell(table_width, row_height * 2, group_label, 'LR', 1, 'L')
  282. pdf.SetFontStyle('', 8)
  283. totals = totals_by_group.map {|column, total| "#{column.caption}: #{total[group]}"}.join(" ")
  284. if totals.present?
  285. pdf.RDMCell(table_width, row_height, totals, 'LR', 1, 'L')
  286. end
  287. previous_group = group
  288. end
  289. # fetch row values
  290. col_values = fetch_row_values(issue, query, level)
  291. # make new page if it doesn't fit on the current one
  292. base_y = pdf.get_y
  293. max_height = get_issues_to_pdf_write_cells(pdf, col_values, col_width)
  294. space_left = page_height - base_y - bottom_margin
  295. if max_height > space_left
  296. pdf.add_page("L")
  297. render_table_header(pdf, query, col_width, row_height, table_width)
  298. base_y = pdf.get_y
  299. end
  300. # write the cells on page
  301. issues_to_pdf_write_cells(pdf, col_values, col_width, max_height)
  302. pdf.set_y(base_y + max_height)
  303. query.block_columns.each do |column|
  304. is_html = false
  305. if column.is_a?(QueryCustomFieldColumn)
  306. cv =
  307. issue.visible_custom_field_values.detect do |v|
  308. v.custom_field_id == column.custom_field.id
  309. end
  310. is_html = cv.custom_field.full_text_formatting? if cv
  311. text = show_value(cv, is_html)
  312. else
  313. text = pdf_format_text issue, column.name.to_sym
  314. is_html = true
  315. end
  316. next if text.blank?
  317. pdf.set_x(10)
  318. pdf.set_auto_page_break(true, bottom_margin)
  319. pdf.SetFontStyle('B', 9)
  320. pdf.RDMCell(0, 5, column.caption, "LRT", 1)
  321. pdf.SetFontStyle('', 9)
  322. if is_html
  323. pdf.RDMwriteFormattedCell(0, 5, '', '', text, issue.attachments, "LRB")
  324. else
  325. pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
  326. end
  327. pdf.set_auto_page_break(false)
  328. end
  329. end
  330. if issues.size == Setting.issues_export_limit.to_i
  331. pdf.SetFontStyle('B', 10)
  332. pdf.RDMCell(0, row_height, '...')
  333. end
  334. pdf.output
  335. end
  336. def pdf_format_text(object, attribute)
  337. textilizable(object, attribute,
  338. :only_path => false,
  339. :edit_section_links => false,
  340. :headings => false,
  341. :inline_attachments => false
  342. )
  343. end
  344. def is_cjk?
  345. case current_language.to_s.downcase
  346. when 'ja', 'zh-tw', 'zh', 'ko'
  347. true
  348. else
  349. false
  350. end
  351. end
  352. # fetch row values
  353. def fetch_row_values(issue, query, level)
  354. query.inline_columns.collect do |column|
  355. s =
  356. if column.is_a?(QueryCustomFieldColumn)
  357. cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
  358. show_value(cv, false)
  359. else
  360. value = column.value_object(issue)
  361. case column.name
  362. when :subject
  363. value = " " * level + value
  364. when :attachments
  365. value = value.to_a.map {|a| a.filename}.join("\n")
  366. when :watcher_users
  367. value = value.to_a.join("\n")
  368. end
  369. if value.is_a?(Date)
  370. format_date(value)
  371. elsif value.is_a?(Time)
  372. format_time(value)
  373. elsif value.is_a?(Float)
  374. number_with_delimiter(sprintf('%.2f', value), delimiter: nil)
  375. else
  376. value
  377. end
  378. end
  379. s.to_s
  380. end
  381. end
  382. # calculate columns width
  383. def calc_col_width(issues, query, table_width, pdf)
  384. # calculate statistics
  385. # by captions
  386. pdf.SetFontStyle('B', 8)
  387. margins = pdf.get_margins
  388. col_padding = margins['cell']
  389. col_width_min = query.inline_columns.map {|v| pdf.get_string_width(v.caption) + col_padding}
  390. col_width_max = Array.new(col_width_min)
  391. col_width_avg = Array.new(col_width_min)
  392. col_min = pdf.get_string_width('OO') + col_padding * 2
  393. if table_width > col_min * col_width_avg.length
  394. table_width -= col_min * col_width_avg.length
  395. else
  396. col_min = pdf.get_string_width('O') + col_padding * 2
  397. if table_width > col_min * col_width_avg.length
  398. table_width -= col_min * col_width_avg.length
  399. else
  400. ratio = table_width / col_width_avg.sum
  401. return col_width = col_width_avg.map {|w| w * ratio}
  402. end
  403. end
  404. word_width_max = query.inline_columns.map do |c|
  405. n = 10
  406. c.caption.split.each do |w|
  407. x = pdf.get_string_width(w) + col_padding
  408. n = x if n < x
  409. end
  410. n
  411. end
  412. # by properties of issues
  413. pdf.SetFontStyle('', 8)
  414. k = 1
  415. issue_list(issues) do |issue, level|
  416. k += 1
  417. values = fetch_row_values(issue, query, level)
  418. values.each_with_index do |v, i|
  419. n = pdf.get_string_width(v) + col_padding * 2
  420. col_width_max[i] = n if col_width_max[i] < n
  421. col_width_min[i] = n if col_width_min[i] > n
  422. col_width_avg[i] += n
  423. v.split.each do |w|
  424. x = pdf.get_string_width(w) + col_padding
  425. word_width_max[i] = x if word_width_max[i] < x
  426. end
  427. end
  428. end
  429. col_width_avg.map! {|x| x / k}
  430. # calculate columns width
  431. ratio = table_width / col_width_avg.sum
  432. col_width = col_width_avg.map {|w| w * ratio}
  433. # correct max word width if too many columns
  434. ratio = table_width / word_width_max.sum
  435. word_width_max.map! {|v| v * ratio} if ratio < 1
  436. # correct and lock width of some columns
  437. done = 1
  438. col_fix = []
  439. col_width.each_with_index do |w, i|
  440. if w > col_width_max[i]
  441. col_width[i] = col_width_max[i]
  442. col_fix[i] = 1
  443. done = 0
  444. elsif w < word_width_max[i]
  445. col_width[i] = word_width_max[i]
  446. col_fix[i] = 1
  447. done = 0
  448. else
  449. col_fix[i] = 0
  450. end
  451. end
  452. # iterate while need to correct and lock coluns width
  453. while done == 0
  454. # calculate free & locked columns width
  455. done = 1
  456. ratio = table_width / col_width.sum
  457. # correct columns width
  458. col_width.each_with_index do |w, i|
  459. if col_fix[i] == 0
  460. col_width[i] = w * ratio
  461. # check if column width less then max word width
  462. if col_width[i] < word_width_max[i]
  463. col_width[i] = word_width_max[i]
  464. col_fix[i] = 1
  465. done = 0
  466. elsif col_width[i] > col_width_max[i]
  467. col_width[i] = col_width_max[i]
  468. col_fix[i] = 1
  469. done = 0
  470. end
  471. end
  472. end
  473. end
  474. ratio = table_width / col_width.sum
  475. col_width.map! {|v| v * ratio + col_min}
  476. col_width
  477. end
  478. def render_table_header(pdf, query, col_width, row_height, table_width)
  479. # headers
  480. pdf.SetFontStyle('B', 8)
  481. pdf.set_fill_color(230, 230, 230)
  482. base_x = pdf.get_x
  483. base_y = pdf.get_y
  484. max_height = get_issues_to_pdf_write_cells(pdf, query.inline_columns, col_width, true)
  485. # write the cells on page
  486. issues_to_pdf_write_cells(pdf, query.inline_columns, col_width, max_height, true)
  487. pdf.set_xy(base_x, base_y + max_height)
  488. # rows
  489. pdf.SetFontStyle('', 8)
  490. pdf.set_fill_color(255, 255, 255)
  491. end
  492. # returns the maximum height of MultiCells
  493. def get_issues_to_pdf_write_cells(pdf, col_values, col_widths, head=false)
  494. heights = []
  495. col_values.each_with_index do |column, i|
  496. heights << pdf.get_string_height(col_widths[i], head ? column.caption : column)
  497. end
  498. return heights.max
  499. end
  500. # Renders MultiCells and returns the maximum height used
  501. def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false)
  502. col_values.each_with_index do |column, i|
  503. pdf.RDMMultiCell(col_widths[i], row_height, head ? column.caption : column.strip, 1, '', 1, 0)
  504. end
  505. end
  506. # Draw lines to close the row (MultiCell border drawing in not uniform)
  507. #
  508. # parameter "col_id_width" is not used. it is kept for compatibility.
  509. def issues_to_pdf_draw_borders(pdf, top_x, top_y, lower_y,
  510. col_id_width, col_widths, rtl=false)
  511. col_x = top_x
  512. pdf.line(col_x, top_y, col_x, lower_y) # id right border
  513. col_widths.each do |width|
  514. if rtl
  515. col_x -= width
  516. else
  517. col_x += width
  518. end
  519. pdf.line(col_x, top_y, col_x, lower_y) # columns right border
  520. end
  521. pdf.line(top_x, top_y, top_x, lower_y) # left border
  522. pdf.line(top_x, lower_y, col_x, lower_y) # bottom border
  523. end
  524. end
  525. end
  526. end
  527. end