This question has been flagged
10 Replies
12262 Views

Hello! I am using 14.0 CE and I have a problem with the invoice PDF, the header and the footer with the company info are not showing, I searched and found that could be a problem with the wkhtmltopdf version but I installed multiple versions and still not working, also I search the document template and the template has the header and footer, I don't know why the PDF don't show the header and footer. 

Thanks for the help!

Avatar
Discard
Best Answer

SOLUTION TO HAVE PRINT HEADERS:

I had the same issue, and I was able to resolve it by following shaneebkhan's steps but in this way

The steps are as follows (ChatGPT assisted us with this):

  1. Install wkhtmltopdf on Ubuntu 22: To install wkhtmltopdf on Ubuntu 22, open a terminal and execute the following command:

    sudo apt install wkhtmltopdf
    
  2. Check the current version of wkhtmltopdf: After installation, verify the current version of wkhtmltopdf with the following command:

    wkhtmltopdf --version
    

    If the version is 0.12.6, you will need to remove it and download version 0.12.5.

  3. Uninstall version 0.12.6: Open a terminal and execute the following command to uninstall the current version of wkhtmltopdf (0.12.6):

    sudo apt remove wkhtmltopdf
    

    Then, if you wish, you can remove unused dependencies with the command:

    sudo apt autoremove
    
  4. Download and install version 0.12.5: Download the deb package of wkhtmltopdf version 0.12.5 with the following command (make sure to copy the entire command):

    wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
    

    Next, install the downloaded package along with the required fonts:

    sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
    sudo apt-get install xfonts-75dpi
    sudo apt-get update
    
  5. Fix broken packages (if necessary): If, after following the previous steps, you encounter broken packages, you can try to fix them with the following command:

    sudo apt --fix-broken install
    

Once you have followed these steps, verify the wkhtmltopdf version again to confirm that you are now using version 0.12.5 with the following command:

wkhtmltopdf --version

It should display version 0.12.5 if everything went well.

I hope this guide helps you resolve the wkhtmltopdf installation issues and generate reports correctly in Odoo 16. Good luck!

AS A RECOMMENDATION, some cases may require the installation of libssl1.1 to address additional issues. You can try downloading and installing it with the following commands:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.22_amd64.deb
sudo dpkg -i libssl1.1_1.1.1-1ubuntu2.1~18.04.22_amd64.deb


Avatar
Discard

I had to validate the version directly on the /usr/local/bin folder, but it worked!

Best Answer

Hi,

The solution of adding key/value in the system parameters solves a different issue: your report prints without any formating (CSS).

If your reports print without the header and the footer, check the log (error_level = debug). You will certainly view such messages:

WARNING databasename odoo.addons.base.models.ir_actions_report: wkhtmltopdf: b"The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-odoo16'\n"

To solve the problem you have to patch your wkhtml2pdf

Type this command to get the current version

# wkhtmltopdf --version
wkhtmltopdf 0.12.5

After patching your library, you will get the following response

# wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

This will solve the problem.





Avatar
Discard
Best Answer

hi, 

hear the problem was installation of wkhtmltopdf 

i have same issue in odoo 16 finally i corrected by proper installation of wkhtmltopdf

first we have to install wkhtmltopdf ubuntu 22 terminal

      1.    apt install wkhtmltopdf

      2. wkhtmltopdf --version 

      whether its 0.12.6 remove and download 0.12.5

      3.wget https://github\\.com/wkhtmltopdf/wkhtmltopdf/releases/download/0\\.12\\.5/wkhtmltox_0\\.12\\.5\\-1\\.bionic_amd64\\.deb

     \\ 4\\.sudo\\ dpkg\\ \\-i\\ \\ wkhtmltox_0\\.12\\.5\\-1\\.bionic_amd64\\.deb

sometimes\\ it\\ may\\ error\\ then\\ try\\ to\\ install\\ one\\ or\\ two\\ things 

    \\ 1\\.wget\\ http://archive\\.ubuntu\\.com/ubuntu/pool/main/o/openssl/libssl1\\.1_1\\.1\\.1\\-1ubuntu2\\.1\\~18\\.04\\.22_amd64\\.deb

   \\ 2\\.sudo\\ dpkg\\ \\-i\\ libssl1.1_1.1.1-1ubuntu2.1~18.04.22_amd64.deb

    3.sudo apt-get install xfonts-75dpi

    4.sudo apt-get update

    5.apt --fix-broken install


finally confirm  the "wkhtmltopdf version is  0.12.5"

Avatar
Discard
Best Answer

I had the same issue with Odoo 16 on Ubuntu 22.04 (arm64). 

I directly download the qt-patched version 0.12.6.1-2 on https://wkhtmltopdf.org/downloads.html


Avatar
Discard
Best Answer

Wkhtmltopdf version 0.12.5 is not available for Ubuntu 22 arm64. Any hints to have headers and footers back for this architecture?

Avatar
Discard
Best Answer

Has anyone managed to get this working correctly?

I've tried setting the parameter.

All versions of wkhtmltopdf 0.12.6, 0.12.5, 0.12.5 (with patched qt).

All headers are being forwarded as well.

Avatar
Discard
Best Answer

I had the same issue when generating PDF reports for customers. I tried downgrading wkhtmltopdf to version 0.12.5, but it didn't work. 

However, I found the solution to fix it for both versions 0.12.6 and 0.12.5.


My solution was to update the system's proxy. 
Always redirect to HTTPS if you're using HTTPS. 
And set the following values in the header:


```

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto https;

proxy_set_header X-Forwarded-Host $host;

```


You can refer to the template below.

Avatar
Discard

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream odoo_servers {
server 127.0.0.1:8069;
keepalive 16;
}
upstream odoo_chat_servers {
server 127.0.0.1:8072;
}

server {
listen 80;
server_name xxx-xxxx.demo.com;
if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}

access_log /var/log/nginx/xxx-xxxx.demo.com.access.log;
error_log /var/log/nginx/xxx-xxxx.demo.com.error.log;

client_max_body_size 5000M;
proxy_max_temp_file_size 5000M;
proxy_connect_timeout 120s;
proxy_send_timeout 3600;
proxy_read_timeout 3600;

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://odoo_servers;
proxy_http_version 1.1;
}
location /longpolling {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://odoo_chat_servers;
proxy_http_version 1.1;

}
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo_servers;
}

# common gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}

Best Answer

please check the odoo log to see if there is --no-header or --no-footer in the record so please uninstall your wkhtmlopdf and reinstall the latest one which is suitable for your os 

thanks

Avatar
Discard
Best Answer

Hi  Fernanda,

Try adding this record in Settings > Technical > Parameters  > System Parameters

key: report.url

value: your_ip:port

https://www.youtube.com/watch?v=lC9p_QJUW1Q


Avatar
Discard
Author

Thanks for the answer, but I tried your solution and the video and still not working

Can you change the report type to HTML and check, might be some issues with the paper format in PDF

Best Answer

If you are experiencing issues with the header and footer not showing in the invoice PDF in Odoo 14.0 Community Edition, here are a few steps you can take to troubleshoot and resolve the problem:

  1. Check the PDF settings in the company configuration:

    • Go to "Settings" -> "Companies" -> Select your company.
    • In the "Accounting" tab, make sure the "Header" and "Footer" options are enabled.
    • Save the changes and generate a new invoice PDF to see if the header and footer are now visible.
  2. Verify the document template:

    • Navigate to "Accounting" -> "Configuration" -> "Documents" -> "Document Templates".
    • Search for the template used for the invoice report.
    • Open the template and ensure that the header and footer are defined correctly.
    • Verify that the template includes the necessary variables and expressions to display the company information.
  3. Check the installed wkhtmltopdf version:

    • Ensure that you have the correct version of wkhtmltopdf installed and configured for your Odoo instance.
    • The recommended version for Odoo 14 is wkhtmltopdf 0.12.5. You can download it from the official website: https://wkhtmltopdf.org/downloads.html
    • After installation, restart your Odoo server to apply the changes.
  4. Test with different PDF formats:

    • In the company configuration, try changing the PDF format (e.g., from A4 to Letter) and regenerate the invoice PDF to see if the header and footer appear in a different format.
  5. Check server logs:

    • Monitor the server logs for any error messages related to generating the PDF. Look for any warnings or errors related to wkhtmltopdf.
    • Check if there are any permission issues with the Odoo process accessing the wkhtmltopdf executable.

If the above steps do not resolve the issue, you may need to dig deeper into the configuration and template files to identify the cause. Additionally, you can seek assistance from the Odoo community or consider reaching out to Odoo support for further help in troubleshooting and resolving the specific issue you are facing.

Avatar
Discard