Closed staycreativedesign closed 3 years ago
Not entirely sure I understand your question? If you're asking how you'd have the footer show some text (initials) and have them right aligned, then that's pretty easy. Just set the footer_template
to something like:
'<div class='text right'>What ever text you want</div>'
ie:
Grover.new('<some site URI>', footer_template: '<div class='text right'>What ever text you want</div>').to_pdf
or via the global configuration options:
Grover.configure do |config|
config.footer_template = '<div class='text right'>What ever text you want</div>'
end
....
Grover.new('<some site URI>').to_pdf
Of course if you're using the middleware you'd likely need to use the global configuration option ;)
See https://github.com/Studiosity/grover#header-and-footer-templates for the list of classes available for laying out the header/footer
Please note you would also need to specify display_header_footer: true
per https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagepdfoptions
thank you sir!
So I have this in my initializer
Grover.configure do |config|
config.options = {
format: 'A4',
display_header_footer: true,
header_template: "<div class='url'>foobar</div>",
footer_template: "<span class=;pageNumber'></span>/<span class='totalPages'></span>",
margin: {
bottom: 70,
left: 25,
right: 35,
top: 30,
},
print_background: true,
viewport: {
width: 640,
height: 480
},
prefer_css_page_size: true,
emulate_media: 'screen',
cache: false,
timeout: 0, # Timeout in ms. A value of `0` means 'no timeout'
launch_args: ['--font-render-hinting=medium'],
wait_until: 'domcontentloaded'
}
end
in my controller
def contract
html = render_to_string({
template: 'pages/contract',
layout: 'contract.haml'
})
pdf = Grover.new(html).to_pdf
send_data pdf
end
nothing in the footer what I do wrong here?!
Likely related to the invalid HTML class attribute.. semicolon instead of a quote
You'd also likely want to wrap the spans in a div with the text
class. The default with chrome is really small text. It's there, you just can't see it unless you zoom right in. Ie
<div class='text'>what ever</div>
that was in my example above ;)
Thank you sir!
%footer{:style => "font-size:16px;margin-left: 80%;"}
This hack works
Ok to resolve this @staycreativedesign ?
Ok to resolve this @staycreativedesign ?
Yes it is :)
How can I have it on the footer right hand side to have a line with initials on the bottom?