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 7777359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:07:20+00:00 2026-06-01T18:07:20+00:00

I would like to create a prawn table where cell text is wrapped by

  • 0

I would like to create a prawn table where cell text is wrapped by words and not letters. I am already using shrink_to_fit, but it seems that prawn is wrapping based on letters. I would ideally want it to wrap on words alone (single_line is not an option since there can be 2-3 words per cell).

Anyone knows how to do that ?

  • 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-01T18:07:22+00:00Added an answer on June 1, 2026 at 6:07 pm

    Maybe your table contains words that are too long for a single table cell? As far as I know, table cells in Prawn tables use bounding boxes which should wrap the text automatically. The following example works fine for me:

    Prawn::Document.generate 'example.pdf' do
      data = [['Pig','Oink '*10],
              ['Cow','Moo '*10],
              ['Duck','Quack '*10]]
      table data do |table|
        table.column_widths = [50,150]
      end
    end
    

    If nothing works, you could try building your own table with multiple text_box calls instead of using the built-in Prawn table method, this is of course a bit cumbersome. text_box draws the requested text into a box. The :overflow parameter controls the behavior when the amount of text exceeds the available space, available options are :truncate, :shrink_to_fit, or :expand.

    text_box(txt, :at => [x,y], :width => width, :height => height, :size => size,
                  :overflow => :shrink_to_fit,..)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a table to store device settings. The table has
I would like create same as on stackoverflow - orange comunnicates, but i have
I would like create a very simple Paint application using MAF on WPF. The
I would like create a database using value from a variable. Here my script
would like to create a function that generates graphs using ggplot. For the sake
I would like to create a textbox which accepts text in english only and
I would like create an animation like the iOS 5 banner notifications, but i
I would like to create an App with python, but i need that it
I am using Wicket and would like to create a grid of radio buttons
i would like create a array of structure which have a dynamic array :

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.