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

Error with Header and footer options on Windows platform #44

Closed
mperez123 opened this issue Jul 8, 2011 · 6 comments
Closed

Error with Header and footer options on Windows platform #44

mperez123 opened this issue Jul 8, 2011 · 6 comments

Comments

@mperez123
Copy link

I have the next problem.

I am working with RoR 2.3.8 on Windows platform. Also the server run on windows.

I am trying to create a pdf from html template, layout and partials.

briefly i will try to explain what i am trying to do:

My site is a shopping site, so I need generate a voucher.pdf

This voucher could have many items.therefore the voucher could have many pages.

I need to create a header and footer for each page in the voucher. There's mention that without these options (header and / or footer) works perfectly

I try this in my controller

def generate_voucher
@order = Order.find(params[:id])

unless @order.blank?

 pdf = render_to_string_with_wicked_pdf({:pdf    => 'generate_voucher.html.erb',
                                          :layout => 'voucher.html',
                                          :header => {:html => { :template => 'shared/voucher_header.html.erb'} 
                                                                                                          # Also i try voucher_header.pdf.erb
                                         })

  @order.save_pdf(pdf)

  redirect_to :action => "payment", :id => order.id
end

end

This message throw:

'Template is missing

Missing template shared/voucher_header.html.erb in view path app/views'

I need to use a header and footer on every pages of the pdf file and not display it.

Also when i render a image with wicked_pdf_image_tag diaplay a empty frame with grey border.

Thanks in advance and excuse me.

@unixmonkey
Copy link
Collaborator

The header line looks good to me, is shared/voucher_header.html.erb right? or is it shared/_voucher_header.html.erb?
Usually shared is a place to put partials. Passing :template assumes a full correct filename, not the magic stripping of the leading underscore like render :partial does.

Not sure about your issue with images, does windows not work with file:// descriptors?
You can check what is actually being rendered in the html by passing :debug => true in your render.

@mperez123
Copy link
Author

Thank you very much.

@mperez123
Copy link
Author

When I paste the url generated in browser this show the image correctly. However in image tag don´t show the image.

@mperez123 mperez123 reopened this Jul 8, 2011
@unixmonkey
Copy link
Collaborator

Are you using wicked_pdf_image_tag or just image_tag? You can try defining a new helper as mentioned here:
#1

def pdf_image_tag(image, options = {})
  options[:src] = File.expand_path(RAILS_ROOT) + '/public/images/' + image_tag(:img, options)
end

I guess I should really try and get a windows computer together to test this stuff better on that platform

@mperez123
Copy link
Author

Thanks. I am using pdf_image_tag on windows. My problem now is how could i generate multipages pdf with a standard header and footer (I need repeat these).

@mperez123 mperez123 reopened this Jul 12, 2011
@unixmonkey
Copy link
Collaborator

You have a lot of flexibility in specifying your headers and footers.
Here, the header is a template, and the footer is built up with some standard text.

render :pdf => 'file',
            :header =>  { :html => { :template => 'shared/header.pdf.erb' } },
            :footer   => {:left => 'REPORT',
                                 :center => Time.now.to_s(:db),
                                 :right => '[page] of [topage]'}

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

No branches or pull requests

2 participants