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

  • Home
  • SEARCH
  • 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 822771
In Process

The Archive Base Latest Questions

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

I have two PDFs that are made on the fly using Prawn PDF. The

  • 0

I have two PDFs that are made “on the fly” using Prawn PDF.

The PDFs are called jobsheet.pdf and discharge.pdf – their URLs are:

railsroot/kases/IDNO/jobsheet.pdf
railsroot/kases/IDNO/discharge.pdf

I am trying to work out how to automagically append the filename with the ID number:

railsroot/kases/IDNO/jobsheet_IDNO.pdf
railsroot/kases/IDNO/discharge_IDNO.pdf

To create the PDFs the code is as follows:

Kases Controller

def jobsheet
    @kase = Kase.find(params[:id])

    respond_to do |format|
      format.html {} # jobsheet.html.erb
      format.xml  { render :xml => @kase }
      format.pdf { render :layout => false }

      prawnto :prawn => { 
                 :background => "#{RAILS_ROOT}/public/images/jobsheet.png", 
                 :left_margin => 0, 
                 :right_margin => 0, 
                 :top_margin => 0, 
                 :bottom_margin => 0, 
                 :page_size => 'A4' }
    end

  end

  # GET /kases/1
  # GET /kases/1.xml
  def discharge
    @kase = Kase.find(params[:id])

    respond_to do |format|
      format.html { } # discharge.html.erb
      format.xml  { render :xml => @kase }
      format.pdf { render :layout => false }

      prawnto :prawn => { 
                 :background => "#{RAILS_ROOT}/public/images/discharge.png", 
                 :left_margin => 0, 
                 :right_margin => 0, 
                 :top_margin => 0, 
                 :bottom_margin => 0, 
                 :page_size => 'A4' }
    end

  end

Routes

 map.resources :kases, :member => { :discharge => :get }
  map.resources :kases, :member => { :jobsheet => :get }

To view the PDFs I use the following links:

jobsheet_kase_path(@kase, :format => 'pdf')
discharge_kase_path(@kase, :format => 'pdf')

Is this even possible?

Thanks,

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

    From the prawnto documentation it looks like the prawnto method supports passing a file name as part of the options hash. So you should be able to do something like this:

    def jobsheet 
      @kase = Kase.find(params[:id]) 
    
      respond_to do |format| 
        format.html # jobsheet.html.erb 
        format.xml { render :xml => @kase } 
        format.pdf { render :layout => false } 
    
        prawnto :filename => "jobsheet_#{@kase.id}", :prawn => {  
          :background => "#{RAILS_ROOT}/public/images/jobsheet.png",          
          :left_margin => 0,  
          :right_margin => 0,  
          :top_margin => 0,  
          :bottom_margin => 0,  
          :page_size => 'A4' } 
      end 
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two applications written in Java that communicate with each other using XML
http://www.brixwork.com/realtors/blog/marketing-promotion/combining-pdfs-online-for-a-comprehensive-presentation/ I have two occurrences of <ol><li> s in this blog post. The first
I have two methods that draw a rotated rectangle on the screen. RenderMethod1 renders
I have two classes that extend the activity class. Each class has it's own
Let's say I have two PDF templates created with Adobe Acrobat, which are both
I have some PDF's all with two attached files with static names. I would
I have to generate roughly 18,000 PDFs that contain sensitive information. The PDFs will
I have a PHP application that needs to generate some PDF invoices and PDF
We have 5,000 PDFs that should, in total, be no larger than 200gb. They
Have two separate databases. The master that holds the user information(username, password, address etc.).

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.