[GNC] PDF filenames for reports

Matthijs Kooijman matthijs at stdin.nl
Sun Jan 20 06:32:34 EST 2019


Hi folks,

I'm replying to this old thread, adding a bit more info for anyone
searching for this on Google (hopefully the mailing list archive will
add this post to the existing thread...).

> Ok, in dconf you will want to look for
> /org/gnucash/general/report/pdf-export/(filename-format and filename-
> date-format)

I've found these dconf values and changing them works (gnucash 2.6.15).

However, I wanted to use just the invoice number as the filename, so I
changed the value from the default "%1$s-%2$s-%3$s" to "%2$s". Clicking
PDF export on an invoice then crashed Gnucash, with an assertion
failure: *** invalid %N$ use detected ***

This is because printf does not support skipping arguments (when there
is no format string for an argument, printf has no idea how big it is on
the stack, so it cannot tell where the next argument begins).

In this case, I found a simple workaround in the "precision" specifier
of printf format strings. For string arguments, the precision is used as
the maximum string width, truncating any longer strings. So you can add
a zero-width specifier for any arguments that you want to skip. E.g. it
works with "%1$.0s%2$s" (note that argument 3 can be left out, since it
is at the end).

Just in case anyone else runs into this :-)

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20190120/a1ab056e/attachment.sig>


More information about the gnucash-user mailing list