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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:05:34+00:00 2026-05-16T05:05:34+00:00

I am using Prawn PDF to create PDF files on the fly in my

  • 0

I am using Prawn PDF to create PDF files on the fly in my Rails application.

I recently came across the rails cell.blank? function, which has proved to be really handy, I can hide any <li> rows I want if there is nothing to display – something I have been wondering about for a while!

Is it possible to do the same in Prawn? Hide a line if it’s empty?

At the moment if I have the following:

Contact Name
Address Line 1
Address Line 2
Address Line 3
Postcode
Phone Number
Fax Number

If, for example, the user only entered the contact name and postcode there would be a significant gap where the Address Line’s 1, 2 and 3 should be.

If I could ignore those rows because they are empty and display it as:

Contact Name
Postcode

it would tidy up my PDF and save the user having to use the incorrect field to ensure the address looks right in the PDF.

This is what my Prawn code looks like:

pdf.text_box "Client", :size => 9, :at => [50,673]
    pdf.text_box "#{@kase.company.companyname}", :size => 9, :at => [100,673]
    pdf.text_box "#{@kase.company.companyaddressline1}", :size => 9, :at => [100,665]
    pdf.text_box "#{@kase.company.companyaddressline2}", :size => 9, :at => [100,655]
    pdf.text_box "#{@kase.company.companyaddressline3}", :size => 9, :at => [100,645]
    pdf.text_box "#{@kase.company.companyaddresscity}", :size => 9, :at => [100,635]
    pdf.text_box "#{@kase.company.companyaddresspostcode}", :size => 9, :at => [100,625]

I have searched the Prawn google user group site but can’t seem to find what I need.

Thanks in advance!

Danny

  • 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-05-16T05:05:34+00:00Added an answer on May 16, 2026 at 5:05 am

    pdf bounding box (shamelessly yanked from the prawn documentation).

       pdf.bounding_box([100,400], :width => 400) do
         pdf.text("The height of this box is #{pdf.bounds.height}")
         pdf.text('this is some text')
         pdf.text('this is some more text')
         pdf.text('and finally a bit more')
         pdf.text("Now the height of this box is #{pdf.bounds.height}")
       end
    

    can be easily modified to print if the attribute is available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a pdf version of our rails application using the Prawn plugin,
I'm using prawn with prawnto in a rails 3 application to generate some pdf's.
I have two PDFs that are made on the fly using Prawn PDF. The
Im using prawn to generate a PDF output in a rails app. How do
I'm using Prawn and Prawnto to generate a PDF in a Ruby on Rails
I generate a PDF file using Prawn and the Prawnto plugin in my rails
I'm working on a Rails application that uses prawn to generate PDF's. Long story
I'm using the Prawn Ruby library ( http://prawn.majesticseacreature.com/ ) to generate some pdf documents.
I'm a little stuck on using Prawn/Prawnto to generate PDF documents. The Prawn documentation
Is anyone using Prawn / Prawnto with Jruby on rails? I installed prawn 0.5.01

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.