diff --git a/report_qweb_signer/data/defaults.xml b/report_qweb_signer/data/defaults.xml
index 9b0f92af8..959d37593 100644
--- a/report_qweb_signer/data/defaults.xml
+++ b/report_qweb_signer/data/defaults.xml
@@ -2,6 +2,10 @@
report_qweb_signer.java_parameters
- -Xms4M -Xmx4M -XX:CompressedClassSpaceSize=256m
+ -Xms16M -Xmx16M -XX:CompressedClassSpaceSize=256m
+
+
+ report_qweb_signer.java_position_parameters
+ -llx 400 -lly 820 -urx 600 -ury 100 -fs 8
diff --git a/report_qweb_signer/demo/report_partner_demo.xml b/report_qweb_signer/demo/report_partner_demo.xml
index 84bdc71a0..dea7a775d 100644
--- a/report_qweb_signer/demo/report_partner_demo.xml
+++ b/report_qweb_signer/demo/report_partner_demo.xml
@@ -33,14 +33,16 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
+
+ Test PDF certificate
+ res.partner
+ qweb-pdf
+ report_qweb_signer.report_partner_demo
+ 'test_' + (object.name or '').replace(' ', '_').lower() + '.pdf'
+ True
+
+ report
+
diff --git a/report_qweb_signer/models/ir_actions_report.py b/report_qweb_signer/models/ir_actions_report.py
index 4db4237c7..e5653990a 100644
--- a/report_qweb_signer/models/ir_actions_report.py
+++ b/report_qweb_signer/models/ir_actions_report.py
@@ -122,8 +122,13 @@ class IrActionsReport(models.Model):
irc_param = self.env["ir.config_parameter"].sudo()
java_bin = "java -jar"
java_param = irc_param.get_param("report_qweb_signer.java_parameters")
- jar = "{}/../static/jar/jPdfSign.jar".format(me)
- return "{} {} {} {}".format(java_bin, java_param, jar, opts)
+ java_position_param = irc_param.get_param(
+ "report_qweb_signer.java_position_parameters"
+ )
+ jar = "{}/../static/jar/JSignPdf.jar".format(me)
+ return "{} {} {} {} {}".format(
+ java_bin, java_param, jar, opts, java_position_param
+ )
def _get_endesive_params(self, certificate):
date = datetime.datetime.utcnow() - datetime.timedelta(hours=12)
@@ -160,7 +165,7 @@ class IrActionsReport(models.Model):
return pdfsigned
def pdf_sign(self, pdf, certificate):
- pdfsigned = pdf + ".signed.pdf"
+ pdfsigned = pdf[:-4] + "_signed.pdf"
p12 = _normalize_filepath(certificate.path)
passwd = _normalize_filepath(certificate.password_file)
method_used = certificate.signing_method
@@ -169,7 +174,12 @@ class IrActionsReport(models.Model):
_("Signing report (PDF): " "Certificate or password file not found")
)
if method_used == "java":
- signer_opts = '"{}" "{}" "{}" "{}"'.format(p12, pdf, pdfsigned, passwd)
+ passwd_f = open(passwd, "tr")
+ passwd = passwd_f.read().strip()
+ passwd_f.close()
+ signer_opts = ' "{}" -ksf "{}" -ksp "{}" -V -d "/tmp"'.format(
+ pdf, p12, passwd
+ )
signer = self._signer_bin(signer_opts)
process = subprocess.Popen(
signer, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
@@ -220,7 +230,7 @@ class IrActionsReport(models.Model):
for fname in (pdf, signed):
try:
os.unlink(fname)
- except (OSError, IOError):
+ except OSError:
_logger.error("Error when trying to remove file %s", fname)
if certificate.attachment:
self._attach_signed_write(res_ids, certificate, content)
diff --git a/report_qweb_signer/models/report_certificate.py b/report_qweb_signer/models/report_certificate.py
index 6159fa176..4a1e62512 100644
--- a/report_qweb_signer/models/report_certificate.py
+++ b/report_qweb_signer/models/report_certificate.py
@@ -31,6 +31,7 @@ class ReportCertificate(models.Model):
required=True,
comodel_name="ir.model",
help="Model where apply this certificate",
+ ondelete="cascade",
)
domain = fields.Char(
string="Domain", help="Domain for filtering if sign or not the document",
diff --git a/report_qweb_signer/readme/CONTRIBUTORS.rst b/report_qweb_signer/readme/CONTRIBUTORS.rst
index b8f0c6c7e..9b6a265ad 100644
--- a/report_qweb_signer/readme/CONTRIBUTORS.rst
+++ b/report_qweb_signer/readme/CONTRIBUTORS.rst
@@ -5,3 +5,5 @@
* Pedro M. Baeza
* Jairo Llopis
* David Vidal
+* Santi Argüeso
+* Omar Castiñeira
diff --git a/report_qweb_signer/readme/CREDITS.rst b/report_qweb_signer/readme/CREDITS.rst
index 14593eb9d..49127c54a 100644
--- a/report_qweb_signer/readme/CREDITS.rst
+++ b/report_qweb_signer/readme/CREDITS.rst
@@ -1,9 +1,7 @@
External utilities
++++++++++++++++++
-* iText v1.4.8: © 2000-2006, Paulo Soares, Bruno Lowagie and others - License `MPL `__ or `LGPL2 `__ - http://sourceforge.net/projects/itext
-* jPdfSign: © 2006 Jan Peter Stotz - License `MPL `__ or `LGPL2 `__ (inherited from iText) - http://private.sit.fraunhofer.de/~stotz/software/jpdfsign
-* Modified jPdfSign: © 2015 Antonio Espinosa - License `MPL `__ or `LGPL2 `__ (inherited from iText) - static/src/java/JPdfSign.java
+* JSignPdf: © Josef Cacek - License `MPL `__ or `LGPL2 `__ - http://jsignpdf.sourceforge.net/
Icon
++++
diff --git a/report_qweb_signer/readme/ROADMAP.rst b/report_qweb_signer/readme/ROADMAP.rst
index db930cb21..f5bc87ca1 100644
--- a/report_qweb_signer/readme/ROADMAP.rst
+++ b/report_qweb_signer/readme/ROADMAP.rst
@@ -1,5 +1,4 @@
* When signing multiple documents (if 'Allow only one document' is disable)
then 'Save as attachment' is not applied and signed result is not
saved as attachment.
-* To have a visible signature through an image embedded in the resulting PDF.
* Add tests.
diff --git a/report_qweb_signer/static/jar/JSignPdf.jar b/report_qweb_signer/static/jar/JSignPdf.jar
new file mode 100644
index 000000000..27de18c27
Binary files /dev/null and b/report_qweb_signer/static/jar/JSignPdf.jar differ
diff --git a/report_qweb_signer/static/jar/itext-1.4.8.jar b/report_qweb_signer/static/jar/itext-1.4.8.jar
deleted file mode 100644
index dbbd4280c..000000000
Binary files a/report_qweb_signer/static/jar/itext-1.4.8.jar and /dev/null differ
diff --git a/report_qweb_signer/static/jar/jPdfSign.jar b/report_qweb_signer/static/jar/jPdfSign.jar
deleted file mode 100644
index 784b11fc6..000000000
Binary files a/report_qweb_signer/static/jar/jPdfSign.jar and /dev/null differ
diff --git a/requirements.txt b/requirements.txt
index 298ff2a87..66dfb2dcb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,3 +2,4 @@ py3o.template
py3o.formats
genshi>=0.7
cryptography
+endesive