Hey
So if you don’t have any new lines in your WYSIWYG field you will not have formatting issue
e.g
<table style="border-collapse:collapse;width:100%;" border="1">
<tbody>
<tr>
<td style="width:23.558%;">Title1</td>
<td style="width:23.558%;">Title2</td>
<td style="width:23.558%;">Title3</td>
<td style="width:23.558%;">Title4</td>
</tr>
<tr>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
</tr>
<tr>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
<td style="width:23.558%;">test</td>
</tr>
</tbody>
</table>
the above will cause formatting issue
But the same without new lines
<table style="border-collapse:collapse;width:100%;" border="1"><tbody><tr><td style="width:23.558%;">Title1</td><td style="width:23.558%;">Title2</td><td style="width:23.558%;">Title3</td><td style="width:23.558%;">Title4</td></tr><tr><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td></tr><tr><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td><td style="width:23.558%;">test</td></tr></tbody></table>
will not give you formatting issues
Now that the issue is identified the fix
- don’t add new lines WYSIWYG
- Add a before save logic hook that replaces new lines with a space in the WYSIWYG field
- Have a look at the modules/AOS_PDF_Templates/generatePdf.php line 138
replace
$printable = str_replace("\n", "<br />", (string) $converted);
with
$printable = $converted;
But this might have wider consequences
My suggestion is 2nd option
After fixing
The logic hook will look like
custom/Extension/modules/AOS_Products/Ext/Logichooks/cleanWYSIWYG.php
<?php
$hook_array['before_save'][] = Array(1, 'Clean WYSIWYG', 'custom/modules/AOS_Products/cleanWYSIWYG.php','cleanWYSIWYG', 'do_clean');
custom/modules/AOS_Products/cleanWYSIWYG.php
<?php
class cleanWYSIWYG
{
public function do_clean($bean){
$bean->specs_c=str_replace("\r\n",' ',$bean->specs_c);
}
}
