Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8342675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:50:27+00:00 2026-06-09T05:50:27+00:00

We are generating pdf for invoice with prawn in rails 3.1.4. header =[[ Date,

  • 0

We are generating pdf for invoice with prawn in rails 3.1.4.

  header =[[  "Date", "#", "sample name", "model","lease item", "hours", "$/hour", "Total"]]
  items = @invoice.invoice_items.map do |item|
    [
                item.lease_usage_record.lease_usage_items.map do |li|
                [
                  li.lease_date.strftime("%Y-%m-%d"),
                  item.lease_usage_record_id,
                  li.sample_name,
                  li.sample_model_num,
                  li.lease_item.short_name,          
                  li.total_hour,
                  li.charge_rate,
                  li.subtotal
                ]
                end
    ] 
  end
items = header + items
pdf.table items, :header => true, :width => 480 
t = pdf.make_table([ ["                                                       ", "Total:     ","    #{@invoice.total}"] ])
t.draw

It works with a problem. The problem is that all the data cells are squeezed into the first column which is “Date”. Tried to add one one more [] to header and it generated error of “data is 2-dimensional array…”. How to align each column properly under its header? Thanks so much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:50:28+00:00Added an answer on June 9, 2026 at 5:50 am

    The problem was solved by reducing the dimension of the data (items) to 2 dimension. The prawn can only take 2 dimensional data. The following line does the trick:

    items = items.flatten(2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating pdf invoice using fpdf. Some invoices containing many items, and details
Rails 2, PDFkit 0.5.0 Im generating a PDF from a View in Rails 2
TL;DR: I have problems with PHP generating PDF's longer than 1 page total. Hello
I have worked on generating PDF about 3 years ago and used FPDF lib
I am generating PDF/HTML report from a BIRT template. I am using visibility property
I'm generating pdf using ReportLab. But when i'm trying to attach image in it,
I am writing some XML -> PDF generating templates in Apache FOP for an
i am writing some code in vb.net that will be generating a pdf file.
Below is my Code I am generating Password Protected pdf from ItextSharp. Actually two
Am generating a hidden fields like so: @helper.input(_form(userID), '_label-> None) { (id, name, value,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.