I'm using the wkhtmltopdf library to generate PDF files with options
--toc-header-text TEXT --xsl-style-sheet config/wkhtmltopdf_toc.xsl
but the --toc-header-text
value is not inserted to the generated table of contents.
Is there a way to insert the value of --toc-header-text
variable to the custom TOC stylesheet?
ok, it's not an answer, but it is working workaround
I create a temp file with toc stylesheet for each generated pdf, replace title text with my dynamic content and pass this file to wkhtmltopdf
in Ruby it can be something like:
toc_file = Tempfile.new
toc_content = File.
read('config/wkhtmltopdf_toc.xsl').
gsub(':index_title', title)
toc_file.write(toc_content)
toc_file.rewind
pass the file path to wkhtmltopdf -- toc_file.path
destroy the file after pdf is generated:
toc_file.close
toc_file.unlink