Skip to Content
Menu
This question has been flagged
8 Replies
2381 Views

Hello everyone

I have been getting this weird generated PDF (images are below) in a MacBook Pro Apple Silicon, the logo looks fine but the text doesn't and sometimes it's not shown at all, it's in Quotation, Sales Order...

I have tried everything:

And nothing works , the thing is sometimes it works just fine and sometimes doesn't and i can't understand the pattern.

Has anyone encounter this error before I would be glad if you can help

Images of the generate PDF:





Avatar
Discard

I do have the same issue, were you able to solve it?

Best Answer

Hi,

Please ensure wkhtmltopdf has proper permissions to access the files and directories it needs. Run chmod +x /usr/local/bin/wkhtmltopdf to make it executable and verify the webkit_path points to the correct location of the installed wkhtmltopdf. You can check the path with which wkhtmltopdf.

Avatar
Discard
Author

I did run "sudo chmod +x /usr/local/bin/wkhtmltopdf" and add webkit_path: /usr/local/bin/wkhtmltopdf to the system parameters as well. and unfortunately I keep getting these weird PDF from time to time. am thinking it has issues with the Rosetta 2 as there are not arm version for the wkhtmltopdf.

Check repositories like https://packagist.org/packages/houseoftech/wkhtmltopdf-arm64 that offer pre-built ARM versions.

Best Answer

Hi,
Can you try installing wkhtmltopdf 0.12.5 and see if it makes any difference ?
Thanks

Avatar
Discard
Author

Hey Niyas, thanks for your replay, and I did. I already tried that as i had same issues with wkhtmltopdf 0.12.6 in ubuntu in the past and i downgrade to 0.12.5 and it worked fine in Ubuntu, so i thought I'll do the same in MacOS, but unfortunately it didn't work and kept getting those weird text pdfs in 0.12.5 as well

Best Answer

Hello,

Are you able to solve the issue?

Avatar
Discard
Best Answer

I have the same problem on m2 pro running macOS 15.2. 

Tried to install in rosetta mode and odoo prints wrong fonts, no fonts and blanks. I have tried the the webkit path, report.url in all different ways possible, nothing works. Sometimes it will print properly but mostly its completely wrong.

I have installed 0.12.6 and 0.12.5 all version of them as well

Has anyone found a solution to this?

Avatar
Discard

Anybody found a solution to this?

I tried the Mac ports version but unfortunately it wasn’t qt patched and so it didn’t work.

Best Answer

The PDF rendering issue you are experiencing on MacOS when using Odoo might be related to the wkhtmltopdf configuration, font rendering, or compatibility with the macOS platform. Below are some steps and suggestions to resolve this issue:

Troubleshooting Steps:

1. Font Rendering Issue

  • Ensure Fonts Are Installed Correctly:
    • Install any custom fonts required for the report on the MacOS system.
    • Check if the fonts used in the Odoo templates are supported by wkhtmltopdf.
  • Embed Fonts in the Template:
    • Use CSS in your report templates to explicitly include or embed fonts.
    @font-face {
        font-family: 'CustomFont';
        src: url('path/to/font.woff') format('woff');
    }
    body {
        font-family: 'CustomFont', sans-serif;
    }
    

2. Verify wkhtmltopdf Configuration

  • Install the Correct Version:
    • Use version 0.12.5 or 0.12.6 of wkhtmltopdf, which is known to work well with Odoo. Ensure it matches the architecture (ARM or Intel-based Mac).
  • Set Path Correctly:
    • Confirm the path in odoo.conf:
      [options]
      webkit_path = /usr/local/bin/wkhtmltopdf
      
    • Restart Odoo after making changes:
      sudo service odoo restart
      
  • Test Command-Line Rendering: Run wkhtmltopdf from the terminal to check if it produces consistent results:
    wkhtmltopdf http://example.com test.pdf
    

3. Update Report URL

  • Add the following to odoo.conf:
    report.url = http://127.0.0.1:8069
    
  • Restart Odoo to apply the changes.

4. Debug Rendering Behavior

  • Open browser developer tools and inspect how the report appears in the browser before rendering.
  • Check for any errors in Odoo's log file during report generation.

5. Verify CSS and Template Consistency

  • Ensure consistent font and CSS usage in your report template.
  • Sometimes, conflicting CSS rules can cause issues with PDF rendering.

Recommendations for Better Compatibility

Switch to a Different PDF Rendering Library

If wkhtmltopdf is unreliable, consider switching to an alternative library like WeasyPrint. You can install and configure it for Odoo as follows:

  1. Install WeasyPrint:
    pip install weasyprint
    
  2. Configure Odoo to Use WeasyPrint: Modify your report templates or write a custom module to use WeasyPrint instead of wkhtmltopdf.

Check for Odoo Updates or Patches

Verify if there are any updates or patches for your version of Odoo that address PDF generation issues.

Use a Virtual Environment

Run wkhtmltopdf in a virtualized Linux environment (e.g., Docker) to avoid Mac-specific issues.

Summary

This issue likely stems from font rendering or wkhtmltopdf inconsistencies on MacOS. Start by verifying the fonts, CSS, and wkhtmltopdf installation. If the problem persists, consider alternative solutions like WeasyPrint or using a virtualized environment.

If you need help with any of these steps, let me know!

Avatar
Discard
Best Answer

I had the same problem, and clearing the browser cache resolved it. Try clearing your browser’s cache and then reload the page. On most browsers, you can do this by pressing Ctrl+Shift+Delete (or Cmd+Shift+Delete on macOS) and selecting the cache to clear.

Avatar
Discard
Best Answer

Hi,

Has your problem been solved? 

If so, could you post the solution? I have a Mac M1 and I have the same problem with odoo V17.

Avatar
Discard

i am also looking for the same solution, This issue is may be wkhtmltopdf with rosetta translation. If you got any solution on this update here we are waiting for this. May @odoo Need to do something on this.

Author Best Answer

Notice how it's different each time I print a pdf:

  1. https://imgur.com/a/LNU0Idu
  2. https://imgur.com/a/9yHVYWP
  3. https://imgur.com/a/gL6I41m
  4. https://imgur.com/a/Niphs0D

Notice how the first time the text was not Bold as the second and the third time then it was empty in the forth time, I just don't get it some times it print just fine and sometimes not! 

Avatar
Discard
Related Posts Replies Views Activity
1
May 25
432
0
Nov 24
891
2
Oct 24
828
0
Aug 24
821
0
Aug 24
722