Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields Not Displaying #939

Closed
softe1988 opened this issue Jan 18, 2016 · 8 comments
Closed

Fields Not Displaying #939

softe1988 opened this issue Jan 18, 2016 · 8 comments

Comments

@softe1988
Copy link

I'm creating an invoice and in the client's address, city, state, and zipcode are not being displayed on the page.

@pointlessone
Copy link
Member

Hello @softe1988,

Could you please provide a screenshot and sample code? Generated document may help, too.

@simonetma
Copy link

Here is the error i get when I try to generate with the state uncommented. If I comment it out state, the pdf attached is what get's generated. The city and zipcode are fine.

invoice_pdf.rb

class InvoicePdf < Prawn::Document

  def initialize(billing, view)
    super()
    @billing = billing
    @view = view
    moniker
    logo
    due
    text 
    due
    client_name
    address
    city 
     state
    zipcode
    phone
    services 
    description
    cost
    fee
    total_verbiage
    total
    payment
    thanks
  end

  def logo
    logopath =  "#{Rails.root}/app/assets/images/tree_with_roots.jpg"
    image logopath, :width => 75, :height => 55
    move_down 10
    draw_text "Billing Statement For: ", :at => [0, 575], size: 16
    stroke_color "0000000"
        stroke do
        move_down 10
        horizontal_rule
        end
    end

    def text
        draw_text "Invoice # #{@billing.id}", :at => [0, 600], size: 12
    end

    def moniker
        draw_text "Natural Roots Entertainment", :at => [125, 680], size: 24
    end

    def client_name
        font "Times-Roman" 
        move_down 10
    draw_text "#{@billing.client_name} ", :at => [0, 550], size: 16 
    end

    def address
        move_down 10
    text_box "#{@billing.address} ", :at => [0, 545],:width => 200, :height => 14, size: 14 
    end

    def city
        move_down 10
    draw_text "#{@billing.city} ", :at => [0, 520],:width => 100, :height => 14, size: 14   
    end

    def state
     move_down 10
   draw_text "#{@billing.state} ", :at => [110, 530], size: 16  
    end

    def zipcode
        move_down 10
    draw_text "#{@billing.zipcode} ", :at => [0, 505],:width => 50, :height => 14, size: 14 
    end

    def phone
        move_down 10
    draw_text "#{@billing.phone} ", :at => [0, 490], size: 14   
    end

    def due
        move_down 10
    draw_text " Payment Due Date: #{ @billing.payment_due.strftime('%m/%d/%Y')} ", :at => [300, 600], size: 14  
    end

    def services
        move_down 10
    draw_text " Description of Services: ", :at => [0, 450], size: 14   
    end

    def description
        move_down 10
        text_box "#{ @billing.description_of_services} ", :at => [3, 430], :height => 200, :width => 250, size: 14  
    end

    def cost
        move_down 10
        draw_text " Amount Owed ", :at => [300, 450], size: 14  
    end

    def fee
        draw_text "$#{@billing.amount_owed_usd} ", :at => [305, 420], size: 14
         stroke_color "0000000"
        stroke do
            move_down 100
        horizontal_rule
        end 
    end

    def payment
        move_down 10
        draw_text "Please visit http://www.naturalroots.tv/payments for secure online payment via Stripe.", :at => [0, 80], size: 14    
    end 

    def thanks
        move_down 10
        text_box "We thank you for choosing Natural Roots Entertainment for your film production needs and we look forward to building a lasting relationship with you.", :at => [0, 60], size: 12  
    end

    def total_verbiage
        draw_text " Total Balance ", :at => [0, 180], size: 14  
    end
    def total
        move_down 10
        draw_text "$#{@billing.amount_owed_usd} ", :at => [300, 180], size: 14
        stroke_color "0000000"
        stroke do
        horizontal_line 0, 500, :at => 200
        end
    end
end 

screen shot 2016-01-18 at 8 18 10 am

billings_1 (14).pdf
Uploaded using ZenHub.io

@pointlessone
Copy link
Member

I would advise against subclassing Prawn::Document. Instead create your own class that has an instance of Prawn::Document as a part of its state.

The reason for that is that Prawn::Document has a rather wide API. There's always a chance of API collision. For instance, in this case you redefine the state method which is essential part of the Prawn::Document.

@packetmonkey
Copy link
Contributor

Prawn::View was made for just this, it's part of the experimental API but it should give you the interface you are looking for.

     class Greeter
        include Prawn::View

        def initialize(name)
          @name = name
        end

        def say_hello
          text "Hello, #{@name}!"
        end

        def say_goodbye
          font("Courier") do
            text "Goodbye, #{@name}!"
          end
        end
     end

     greeter = Greeter.new("Gregory")

     greeter.say_hello
     greeter.say_goodbye

     greeter.save_as("greetings.pdf")

@pointlessone
Copy link
Member

@softe1988 @simonetma Is the issue resolved for you?

@simonetma
Copy link

Sorry about that empty message. I haven't had a change to try out the
solution, but im pretty sure that's what it is if you want to close the
issue.

On Tue, Jan 19, 2016 at 3:04 PM, Simone Battiste-Alleyne <
simone.battiste-alleyne@tma1.com> wrote:

On Tue, Jan 19, 2016 at 3:04 PM, Alexander Mankuta <
notifications@github.com> wrote:

@softe1988 https://github.com/softe1988 @simonetma
https://github.com/simonetma Is the issue resolved for you?


Reply to this email directly or view it on GitHub
#939 (comment).

Best Regards,
Simone Battiste-Alleyne
Apprentice Software Developer
Tax Management Associates, Inc.
2225 Coronation Blvd.
Charlotte, NC 28227
simone@tma1.com
www.tma1.com

Best Regards,
Simone Battiste-Alleyne
Apprentice Software Developer
Tax Management Associates, Inc.
2225 Coronation Blvd.
Charlotte, NC 28227
simone@tma1.com
www.tma1.com

@pointlessone
Copy link
Member

@simonetma No problems. I'll close it now. Feel free to reopen if that doesn't solve your issue.

@simonetma
Copy link

sounds good thanks!

On Tue, Jan 19, 2016 at 3:07 PM, Alexander Mankuta <notifications@github.com

wrote:

@simonetma https://github.com/simonetma No problems. I'll close it now.
Feel free to reopen if that doesn't solve your issue.


Reply to this email directly or view it on GitHub
#939 (comment).

Best Regards,
Simone Battiste-Alleyne
Apprentice Software Developer
Tax Management Associates, Inc.
2225 Coronation Blvd.
Charlotte, NC 28227
simone@tma1.com
www.tma1.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants