After upgrading to osTicket v1.9.1-556-gef79e44 when going to print a ticket either open or closed I am receiving the following error:
mPDF error: Text contains invalid UTF-8 character(s)
ticket issue #204 did not fix my issue.
It appears this issue is specifically related to HTML as text only will actually print properly.
v1.9.1-556-gef79e44?
This is what it says...
System Settings and Preferences - osTicket (v1.9.1-556-gef79e44) <--- dunno what that is? It started showing up around 1.9 switch.
How are you merging updates into your repo?
I set up a temp directory and run "git pull origin develop-next" then push it out by running "php setup/cli/manage.php deploy --setup /website/home/osticket_dir"
Could you try
git checkout origin/develop-next
php setup/cli/manage.php deploy /website/home/osticket_dir
_The --setup argument for deploy is only necessary for the initial installation_
Here is what I am getting now:
Note: checking out 'origin/develop-next'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 42159e6... Merge pull request #998 from greezybacon/issue/994
HEAD is now at ef79e44... Merge pull request #1385 from greezybacon/issue/1383
The detached HEAD state is normal. No worries there. Any you should switch to develop as we're finalizing the release of 1.9.4 off of the develop branch and will be staging the release of 1.9.5 off of develop-next
I also have this issue - i'm on: osTicket (v1.9.4-rc5-18-gfa4ef3e)
Just upgraded from 1.8 yesterday.
Could you provide the email or whatever was used to create the ticket or ticket thread that contains invalid UTF-8 chars?
Hi,
I use 1.9.4 release and russian language pack. When staff use russian language at the profile, ticket does not print to pdf with this error:
mPDF error: Text contains invalid UTF-8 character(s)
When staff use english language at the profile - print to pdf is work.
@greezybacon
Could this be a valid solution mentioned here:
http://osticket.com/forum/discussion/80105/upgrade-from-1-9-4-rc3-to-1-9-4-stable#latest
I think this may be a regression when I upgraded to mPDF 5.7.3. I think this is the offending block:
commit b4520569369d214247c5cb40333b3f6eb808dd3a
Author: Jared Hancock <[email protected]>
Date: Wed Oct 1 10:45:44 2014 -0500
mpdf: Upgrade to 5.7.3
diff --git a/include/mpdf/mpdf.php b/include/mpdf/mpdf.php
index 91d310d..81cdfe5 100755
--- a/include/mpdf/mpdf.php
+++ b/include/mpdf/mpdf.php
@@ -30689,11 +31131,7 @@ function purify_utf8($html,$lo=true) {
function purify_utf8_text($txt) {
// For TEXT
// Make sure UTF-8 string of characters
- if ($txt === null) $txt = '';
- if (!$this->is_utf8($txt)) {
- $e = new Exception();
- print $e->getTraceAsString();
- $this->Error("Text contains invalid UTF-8 character(s)"); }
+ if (!$this->is_utf8($txt)) { $this->Error("Text contains invalid UTF-8 character(s)"); }
$txt = preg_replace("/\r/", "", $txt );
Specifically the if ($txt === null) $txt = ''; line. I think in some circumstances the text is blank / null and mPDF doesn't handle that well.
@greezybacon
Thank you. It's work for me.
This is fixed.
$html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
before calling: "$mpdf->WriteHTML($html);"
I find this solution in: http://stackoverflow.com/questions/28736061/how-to-set-mpdf-html-contains-invalid-utf-8-characters
Most helpful comment
$html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
before calling: "$mpdf->WriteHTML($html);"
I find this solution in: http://stackoverflow.com/questions/28736061/how-to-set-mpdf-html-contains-invalid-utf-8-characters