gimli icon indicating copy to clipboard operation
gimli copied to clipboard

toc not working with 0.12.1

Open gimler opened this issue 9 years ago • 5 comments

the toc doesn't work for me with 0.12.1

gimli -f doc.md -w '--footer-right "--toc [page]/[toPage]"'

results in Unknown long argument --toc

gimli -f doc.md -w '--footer-right "toc [page]/[toPage]"'

results in -q specified in incorrect location

gimler avatar Nov 10 '14 11:11 gimler

Hello!

What program is at version 0.12.1? The lastest version of gimli is 0.5.6.

I tested your command in 0.5.6 and it "works", I don't get any error messages but no toc or page numbers. That is because the parameters are in disorder. Your command is

gimli -f doc.md -w '--footer-right "--toc [page]/[toPage]"'

If you reorder the arguments to wkhtmltopdf like this it will work.

gimli -f doc.md -w '--toc --footer-right "[page]/[toPage]"'

walle avatar Nov 10 '14 14:11 walle

i mean wkhtmltopdf 0.12.1 system ubuntu

gimli -f doc/webservices/soap.md -w '--toc --footer-right "[page]/[toPage]"'
Unknown long argument --toc

Name:
  wkhtmltopdf 0.12.1 (with patched qt)

Synopsis:
  wkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <output file>

Document objects:
  wkhtmltopdf is able to put several objects into the output file, an object is
  either a single webpage, a cover webpage or a table of content.  The objects
  are put into the output document in the order they are specified on the
  command line, options can be specified on a per object basis or in the global
  options area. Options from the Global Options section can only be placed in
  the global options area

  A page objects puts the content of a singe webpage into the output document.

  (page)? <input url/file name> [PAGE OPTION]...
  Options for the page object can be placed in the global options and the page
  options areas. The applicable options can be found in the Page Options and 
  Headers And Footer Options sections.

  A cover objects puts the content of a singe webpage into the output document,
  the page does not appear in the table of content, and does not have headers
  and footers.

  cover <input url/file name> [PAGE OPTION]...
  All options that can be specified for a page object can also be specified for
  a cover.

  A table of content object inserts a table of content into the output document.

  toc [TOC OPTION]...
  All options that can be specified for a page object can also be specified for
  a toc, further more the options from the TOC Options section can also be
  applied. The table of content is generated via XSLT which means that it can be
  styled to look however you want it to look. To get an aide of how to do this
  you can dump the default xslt document by supplying the
  --dump-default-toc-xsl, and the outline it works on by supplying
  --dump-outline, see the Outline Options section.

Description:
  Converts one or more HTML pages into a PDF document, using wkhtmltopdf patched
  qt.

Global Options:
      --collate                       Collate when printing multiple copies                                      (default)
      --no-collate                    Do not collate when printing multiple                                      copies
      --copies <number>               Number of copies to print into the pdf                                      file (default 1)
  -H, --extended-help                 Display more extensive help, detailing                                      less common command switches
  -g, --grayscale                     PDF will be generated in grayscale
  -h, --help                          Display help
      --license                       Output license information and exit
  -l, --lowquality                    Generates lower quality pdf/ps. Useful to                                      shrink the result document space
  -O, --orientation <orientation>     Set orientation to Landscape or Portrait                                      (default Portrait)
  -s, --page-size <Size>              Set paper size to: A4, Letter, etc.                                      (default A4)
  -q, --quiet                         Be less verbose
      --read-args-from-stdin          Read command line arguments from stdin
      --title <text>                  The title of the generated pdf file (The                                      title of the first document is used if not                                      specified)
  -V, --version                       Output version information and exit
Page Options:
      --print-media-type              Use print media-type instead of screen
      --no-print-media-type           Do not use print media-type instead of                                      screen (default)
Contact:
  If you experience bugs or want to request new features please visit 
  <https://github.com/wkhtmltopdf/wkhtmltopdf/issues>

tested with both 0.6.0.pre and 0.5.6

gimli --version
Version: 0.6.0.pre

gimler avatar Nov 10 '14 17:11 gimler

The 0.6.0.pre version is experimental and uses another version of wkhtmltopdf. Try uninstalling gimli 0.6.0.pre and use version 0.5.6.

This is my output regarding wkhtmltopdf on ubuntu

[00:26:34] ~ $ which wkhtmltopdf 
/home/walle/.gem/ruby/2.1.3/bin/wkhtmltopdf
[00:26:40] ~ $ /home/walle/.gem/ruby/2.1.3/bin/wkhtmltopdf
You need to specify atleast one input file, and exactly one output file
Use - for stdin or stdout

Name:
  wkhtmltopdf 0.9.6
...

From the output from wkhtmltopdf v 0.12.1 it seems like you should just supply toc instead of --toc, so that should work too. E.g.

gimli -f doc/webservices/soap.md -w 'toc --footer-right "[page]/[toPage]"'

See the Table of Content section on http://wkhtmltopdf.org/usage/wkhtmltopdf.txt

walle avatar Nov 10 '14 23:11 walle

i allready tray this

gimli -f doc/webservices/soap.md -s gimli.css -w 'toc --footer-right "[page]/[toPage]"'
-q specified in incorrect location

i would be nice to have a verbose option -v to see additional debug messages for example the final command that is used to call wkhtmltopdf

gimler avatar Nov 11 '14 08:11 gimler

Could you share your output for

$ which wkhtmltopdf 

and

$ wkhtmltopdf

The -q argument is added here https://github.com/walle/gimli/blob/42828df37711b26fbb4efd608d3c6011a99dbb53/lib/gimli/wkhtmltopdf.rb#L30

The issue seems to be that you have a newer version of wkhtmltopdf installed, and not using the version bundled with gimli. There is a discussion here https://github.com/zakird/wkhtmltopdf_binary_gem/issues/17 about releasing the latest binaries v0.12.x to rubygems. When it is released I will update gimli to match the new command line interface, but until it is released there is not much to do, besides checking versions and matching cli arguments based on that. But it's redundant since a new release should be imminent.

If you can't remove your version of wkhtmltopdf and use the bundled version then my suggestion is that you checkout the source of gimli and run

$ cd gimli
$ bundle
$ bundle exec bin/gimli ...

That should require usage of the bundled version. Another solution might be using the source version and remove the -q argument and using rake to install your modified version. E.g.

$ cd gimli
$ rake install

You could also modify the version in lib/version.rb so you can see which gimli you are using (with gimli -v after you have installed your modified version)

A verbose flag is a good idea, there is already a debug flag, that outputs the html generated. It's used at https://github.com/walle/gimli/blob/28933f225a3ab811fed3637b0258f0f5f43b61b5/lib/gimli/converter.rb#L34.

I have added the wkhtmltopdf command used to the debug output in v0.5.7, so you can update to that version and supply the -d flag to see the command used.

Thank you for using (or trying to use at least in this case ;)) gimli!

walle avatar Nov 11 '14 10:11 walle