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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:47:56+00:00 2026-05-15T02:47:56+00:00

I have read through all relevant posts on Prawn but found no mentioning (even

  • 0

I have read through all relevant posts on Prawn but found no mentioning (even in Prawn’s own documentation) of headers and footers.

However, I did see a demo on Prawnto’s own website about headers and footers. I copied the entire source of that demo just to see if it works but an error of undefined method “header” is complained about. Am I to understand that Prawn took out header and footer recently in the gem or is there something else I need to do first to use header and footer?

The demo page:
http://cracklabs.com/prawnto/code/prawn_demos/source/text/flowing_text_with_header_and_footer

the part of code of concern:

Prawn::Document.generate("flow_with_headers_and_footers.pdf")  do

  header margin_box.top_left do 
      text "Here's My Fancy Header", :size => 25, :align => :center   
  end   

  text "hello world!"
end

And by header, just in case, I mean the snippets of words that appear usually at a corner of every page of a document. Like your account number in your bills pages.

thanks!

  • 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-15T02:47:56+00:00Added an answer on May 15, 2026 at 2:47 am

    @GrantSayer thx for the example, but this will only let you show the current page number, not the total number of pages.

    You can also use the number_pages function for the footer:

    Prawn::Document.generate("page_with_numbering.pdf") do
      text "Hai"
      start_new_page
      text "bai"
      start_new_page
      text "-- Hai again"
      number_pages "<page> in a total of <total>", [bounds.right - 50, 0]
    end
    

    However, in my case I also need to format/style and right align the page numbers to match company style guides. I used go_to_page(k) to create my own header and footer functions, which add the header and footer to each page after all the pages are created. This gives me both styling options and the total number of pages:

    Prawn::Document.generate("footer_example.pdf", :skip_page_creation => true) do
      10.times do
        start_new_page
        text "Some filler text for the page"
      end
    
      # footer
      page_count.times do |i|
        go_to_page(i+1)
        lazy_bounding_box([bounds.right-50, bounds.bottom + 25], :width => 50) {
          text "#{i+1} / #{page_count}"
        }.draw
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read through all PHP documentation on IMAP functions (www.php.net/imap), but didn't find
Okay guys, I have read through all the other posts and question on jQuery
All this might look too trivial but read it through - I have simple
I have read through the solutions to similar problems, but they all seem to
I've read through all of the Spring 3 Web docs: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/spring-web.html but have been
I have read through all I can find but doesn't just work out for
I have read through several articles which are alternatives to using setpixel/getpixel but I
I have read through some tutorials about javascript prototypal inheritance patterns but I am
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
I've read through a number of topics now and have not found one quite

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.