[IMP] use PyPDF2 if possible
parent
2607f55713
commit
7fb80c9258
|
@ -8,6 +8,11 @@ Pdf watermark
|
||||||
|
|
||||||
This module was written to add watermarks (backgrounds) to PDF reports. Because of the way wkhtmltopdf handles headers and footers in the current versions, it is quite impossible to have a background for the complete page using HTML and CSS. That is why this module inserts the image at the PDF level.
|
This module was written to add watermarks (backgrounds) to PDF reports. Because of the way wkhtmltopdf handles headers and footers in the current versions, it is quite impossible to have a background for the complete page using HTML and CSS. That is why this module inserts the image at the PDF level.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
This module works out of the box, but is faster if you install the python library PyPDF2.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
{
|
{
|
||||||
"name": "Pdf watermark",
|
"name": "Pdf watermark",
|
||||||
"version": "10.0.1.0.0",
|
"version": "10.0.1.0.1",
|
||||||
"author": "Therp BV, "
|
"author": "Therp BV, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
|
|
|
@ -3,16 +3,22 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from pyPdf import PdfFileWriter, PdfFileReader
|
|
||||||
from pyPdf.utils import PdfReadError
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from odoo import api, models, tools
|
|
||||||
from PIL import PdfImagePlugin # flake8: noqa
|
|
||||||
|
|
||||||
# PdfImagePlugin must be loaded in order to work PNG to PDF transformation
|
from pyPdf import PdfFileWriter, PdfFileReader
|
||||||
# This issue is related to Pillow creation, as can be seen in its source code:
|
from pyPdf.utils import PdfReadError
|
||||||
# https://github.com/python-pillow/Pillow/blob/master/PIL/PdfImagePlugin.py
|
try:
|
||||||
|
from PyPDF2 import PdfFileWriter, PdfFileReader # pylint: disable=W0404
|
||||||
|
from PyPDF2.utils import PdfReadError # pylint: disable=W0404
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
# we need this to be sure PIL has loaded PDF support
|
||||||
|
from PIL import PdfImagePlugin # noqa: F401
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
from odoo import api, models, tools
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue