Signature in wrong place on pdf

I activated the online sign feature for service orders, but I have an issues with it:
After signing a service order, a new pdf is created. On the bottom of the first page, after the service details, there are 2 signature fields printed, these remain empty. On top of a new, otherwise empty, 2nd page the date of the signature is printed, and on top of a 3rd, otherwise empty, page the signature image is printed.

I am currently using version 21.0.0, but I did try the same with 20.0.3 and even with the alpha version 22.x.x

Am I missing the obvious solution or is this a known bug? I did see this tutorial on how to create a pdf template, but after checking the corrospondig file I could only see and therefore manipulate the signature boxes not the signature itself.

I did some digging, and found the file that prints the signed PDF files:
dolibarr\htdocs\core\ajax\onlineSign.php

In lines 564 ff :

$param['xforimgstart'] = (empty($s['w']) ? 110 : $s['w'] / 2 - 2);
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 38);
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 20);

When printing the signature [yforimgstart] => 259.00000007778 and the signature images are all 180px high with $s[‘h’] = 297.00.

If I change the yforimgstart content and set the image start higher on the page, the signature prints fine. It seems the signature date/image is flushed to the next page by the set y value. Which is weird because there is plenty of room below the signature on the page. It wouldnt print in the signature box but it should still print on the same page.

What would be the “dolibarr” way to adjust these settings or rewrite the file? I dont want to overwrite the sourcecode.

1 Like

Hi @S3R
Which pdf template is it?

The PDF in question is:
dolibarr\htdocs\core\modules\fichinter\doc\pdf_soleil.modules.php
But as mentioned in my previous post, that file does not handle the signature itself. It just prints the box where the signature should be printed later when a user signs the document.
The file dolibarr\htdocs\core\ajax\onlineSign.php seems to handle the signature printing process. But I can not create an override for that file (afaik) . The only solution I found so far is to adjust the x, y params in the source code to prevent the signature from being flushed to the next page. Which is more a workaround than a real solution.

Hi
I was able to reproduce the bug in v. 21.0.0 same as your screenshot but not in 20.0.3 where it is working fine. It is bad practice to use beta(v 21) or alpha(v22) software on production instances!

Please submit a bug report in Github and a pull request if you have a solution!

The last related pull request was this FIX intervention online signature position by W1W1-M · Pull Request #30926 · Dolibarr/dolibarr · GitHub

That’s weird. I did try 20.0.3, 21.0.0 beta and even 22.0.0 alpha all with the same result. I will try to reinstall 20.0.3 again and report back.

[EDIT]:
I just did try 20.0.3 and you are right. The bug did not occur. The signature and date printed fine. I thought I did try that version but either I misconfigured the server during the test or sth else went wrong.

[EDIT2]:
There is a significant difference between the calculated signature positions from 20.0.3 to 21.0.0:

20.0.3:

$param['xforimgstart'] = 111;
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);

21.0.0:

$param['xforimgstart'] = (empty($s['w']) ? 110 : $s['w'] / 2 - 2);
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 38);
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 20);