Customize PDF footer

(13 posts) (2 voices)

Tags:

No tags yet.

  1. phil1308, Blocked

    Hello everyone,
    I'd like to know if it is possible to customize the pages footer in a PDF export (inserting a label, a dynamic label) ?

    Thank you for answers...

  2. myDBR Team, Key Master

    Hi,
    you can use the --footer-html option in wkhtmltopdf. See wkhtmltopdf manual for more info.

    --
    myDBR Team

  3. phil1308, Blocked

    Thank you,
    but I don't see where I can add an option like that ?
    Where do you customize the "command line" while calling wkhtmltopdf in myDBR ?
    I've tried to find the "--header-html" string (used in the actual command line) in all /myDBR/ subdirectory : unsuccessfull...

  4. myDBR Team, Key Master

    See documentation for command options and examples.

    --
    myDBR Team

  5. phil1308, Blocked

    OK thank you, I have found what I needed, and it works.

    Just one comment : it is said that you can stop using default header command by inserting select 'dbr.wkhtmltopdf', "--header-html ''"; : I have tried but it throws an error.
    Also with select 'dbr.wkhtmltopdf', "--header-html";
    Finally I inserted select 'dbr.wkhtmltopdf', "--header-html http://127.0.0.1/myDBR/user/export_header_pdf_empty.php" with a custom empty php file...

  6. myDBR Team, Key Master

    You're missing the empty string parameter for the --header-html.

    select 'dbr.wkhtmltopdf', "--header-html ''";

    --
    myDBR Team

  7. phil1308, Blocked

    No, that is exactly what I have inserted and here is the result :
    There was an error (code:-1073741819) producing the pdf document
    Failed command: C:\"Program Files (x86)"\wkhtmltopdf\wkhtmltopdf -q --header-html '' --margin-top 13 C:\Users\Philippe\AppData\Local\Temp\885460508.html -

  8. myDBR Team, Key Master

    OK,
    try to set the export debug on and run the command from command line without the -q parameter. You should see more information why the command fails.

    --
    myDBR Team

  9. phil1308, Blocked

    Ok, in fact I found what caused the problem : I must intervert ' and " :

    select 'dbr.wkhtmltopdf', '--header-html ""';

    ...works fine !

    But now I have another problem !!
    When I use accentuated characters (remmeber I'm french ;), it doesn't work well !

    Example :
    I have inserted that code :
    select 'dbr.wkhtmltopdf', '--margin-top 10 --header-html "" --margin-bottom 20 --footer-html "http://127.0.0.1/myDBR/user/export_footer_pdf.php?pEtablissement=compiègne';

    ...and here is the generated command line :
    C:\"Program Files (x86)"\wkhtmltopdf\wkhtmltopdf -q --margin-top 10 --header-html "" --margin-bottom 20 --footer-html "http://127.0.0.1/myDBR/user/export_footer_pdf.php?pEtablissement=compiègne C:\Users\Philippe\AppData\Local\Temp\429019811.html -

    How to manage that ?

  10. myDBR Team, Key Master

    Accented characters needs to be encoded in URL's. Also, make sure your footer html has correct charset.

    --
    myDBR Team

  11. phil1308, Blocked

    OK, I understand, but how can I encode that URL (generated by myDBR itself) ?
    What directive, syntax should I use in my myDBR code ?...

    In addition, at this point, my footer html is not used yet...the calling URL is already wrong.

  12. myDBR Team, Key Master

    You urlencode the parameter in SQL. You can make a function out of that.

    --
    myDBR Team

  13. phil1308, Blocked

    Ok, I've solved the problem.

    In myDBR MySQL database I created a function urlencode() and I use it as this :
    select 'dbr.wkhtmltopdf', concat('--margin-top 10 --header-html "" --margin-bottom 20 --footer-html "http://127.0.0.1/myDBR/user/export_footer_pdf.php?pEtablissement=', urlencode(pEtablissement), '"');

    Thank you for your help.


Reply

You must log in to post.