Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: I intend to buy, but some issues? (Read 13524 times) previous topic - next topic

Re: I intend to buy, but some issues?

Reply #15
@dobsun‍ and anyone that needs a perfect solution, please take the following steps the issue will be fixed in the next phprad update.

add this code
Code: [Select]
<meta charset="UTF-8">
in the head tag before <title><?php echo $this->report_title; ?></title> and replace this
Code: [Select]
 body,
 h1,
 h2,
 h3,
 h4,
 h5,
 h6 {
 margin: 0px;
 padding: 0px;
 font-family: Arial, Helvetica, sans-serif;
 }
with this
Code: [Select]
 body,
 h1,
 h2,
 h3,
 h4,
 h5,
 h6 {
 margin: 0px;
 padding: 0px;
 font-family: "DejaVu Sans";
 }
in app/views/layouts/report_layout.php.

Now replace the following
Code: [Select]
 /**
 * DomDocument Manipulation
 * Set the inner html of a page element
 * @return string
 */
 private function setInnerHTML($element, $html)
 {
 $html = htmlentities($html);
 $fragment = $element->ownerDocument->createDocumentFragment();
 $fragment->appendXML($html);
 $clone = $element->cloneNode(); // Get element copy without children
 $clone->appendChild($fragment);
 $element->parentNode->replaceChild($clone, $element);
 }
with this
Code: [Select]
 /**
 * DomDocument Manipulation
 * Set the inner html of a page element
 * @return string
 */
 private function setInnerHTML($element, $html)
 {
 $html = html_entity_decode($html);
 $html = fixWrongUTF8Encoding($html);
 $fragment = $element->ownerDocument->createDocumentFragment();
 $fragment->appendXML($html);
 $clone = $element->cloneNode(); // Get element copy without children
 $clone->appendChild($fragment);
 $element->parentNode->replaceChild($clone, $element);
 }
in system/BaseView.php.

and finally, add this function
Code: [Select]
function fixWrongUTF8Encoding($String) { 
 $fix_accent_list = array(
 // 3 char errors first
 '‚' => '‚', '„' => '„', '…' => '…', '‡' => '‡',
 '‰' => '‰', '‹' => '‹', '‘' => '‘', '’' => '’',
 '“' => '“', '•' => '•', '–' => '–', '—' => '—',
 'â„¢' => '™', '›' => '›', '€' => '€',
 // 2 char errors
 'Â'  => 'Â', 'Æ’'  => 'ƒ', 'Ã'  => 'Ã', 'Ä'  => 'Ä',
 'Ã…'  => 'Å', 'â€'  => '†', 'Æ'  => 'Æ', 'Ç'  => 'Ç',
 'ˆ'  => 'ˆ', 'È'  => 'È', 'É'  => 'É', 'Ê'  => 'Ê',
 'Ë'  => 'Ë', 'Å’'  => 'Œ', 'ÃŒ'  => 'Ì', 'Ž'  => 'Ž',
 'ÃŽ'  => 'Î', 'Ñ'  => 'Ñ', 'Ã’'  => 'Ò', 'Ó'  => 'Ó',
 'â€'  => '”', 'Ô'  => 'Ô', 'Õ'  => 'Õ', 'Ö'  => 'Ö',
 '×'  => '×', 'Ëœ'  => '˜', 'Ø'  => 'Ø', 'Ù'  => 'Ù',
 'Å¡'  => 'š', 'Ú'  => 'Ú', 'Û'  => 'Û', 'Å“'  => 'œ',
 'Ãœ'  => 'Ü', 'ž'  => 'ž', 'Þ'  => 'Þ', 'Ÿ'  => 'Ÿ',
 'ß'  => 'ß', '¡'  => '¡', 'á'  => 'á', '¢'  => '¢',
 'â'  => 'â', '£'  => '£', 'ã'  => 'ã', '¤'  => '¤',
 'ä'  => 'ä', 'Â¥'  => '¥', 'Ã¥'  => 'å', '¦'  => '¦',
 'æ'  => 'æ', '§'  => '§', 'ç'  => 'ç', '¨'  => '¨',
 'è'  => 'è', '©'  => '©', 'é'  => 'é', 'ª'  => 'ª',
 'ê'  => 'ê', '«'  => '«', 'ë'  => 'ë', '¬'  => '¬',
 'ì'  => 'ì', '®'  => '®', 'î'  => 'î', '¯'  => '¯',
 'ï'  => 'ï', '°'  => '°', 'ð'  => 'ð', '±'  => '±',
 'ñ'  => 'ñ', '²'  => '²', 'ò'  => 'ò', '³'  => '³',
 'ó'  => 'ó', '´'  => '´', 'ô'  => 'ô', 'µ'  => 'µ',
 'õ'  => 'õ', '¶'  => '¶', 'ö'  => 'ö', '·'  => '·',
 '÷'  => '÷', '¸'  => '¸', 'ø'  => 'ø', '¹'  => '¹',
 'ù'  => 'ù', 'º'  => 'º', 'ú'  => 'ú', '»'  => '»',
 'û'  => 'û', '¼'  => '¼', 'ü'  => 'ü', '½'  => '½',
 'ý'  => 'ý', '¾'  => '¾', 'þ'  => 'þ', '¿'  => '¿',
 'ÿ'  => 'ÿ', 'À'  => 'À',
 // 1 char errors last
 'Ã' => 'Á', 'Å' => 'Š', 'Ã' => 'Í', 'Ã' => 'Ï',
 'Ã' => 'Ð', 'Ã' => 'Ý', 'Ã' => 'à', 'í' => 'í'
 );
 
 //Cyrillic/Russian characters
 $Cyrillic = [
 'а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п',
 'р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я',
 'А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П',
 'Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я'
 ];
 
 //Cyrillic/Russian characters in UTF-8
 $UTF8Equivalent = ['а','б','в','г','д','е','Ñ‘','ж','з','и','й','к','л','м','н','о','п','Ñ€','с','Ñ‚','у','Ñ„','Ñ…','ц','ч','ш','щ','ÑŠ','Ñ‹','ÑŒ','э','ÑŽ','я', 'А','Б','Ð’','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','Ðœ','Н','О','П', 'Ð ','С','Т','У','Ф','Ð¥','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я'
 ];

 //we get our accent characters and its utf-8 equivalent characters
 $error_chars = array_keys($fix_accent_list);
 $real_chars  = array_values($fix_accent_list);
 
 //we relpace the weird utf-8 accent characters with its appropriate characters
 $String = str_replace($UTF8Equivalent, $Cyrillic, $String);   

 //we replace the weird utf-8 cyrillic characters with its appropriate characters and return it.
 return str_replace($error_chars, $real_chars, $String);
}
to helpers/functions.php.

Now preview and enjoy ;) .



Re: I intend to buy, but some issues?

Reply #16
Hi Willvin,
I'm Using Arabic lang.
I tried exactly as in this post , for print function works perfectly after I add to  Print_layout.php the following
Code: [Select]
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
And
Code: [Select]
font-family: "DejaVu Sans";
and other function Pdf & word stop gave me the error  DOMDocumentFragment::appendXML():,
BUT it not display  correctly , in Arabic,  letters are tied together not separate also its display in  RTL as in the attached .
Pict1 the way it should work ,
Pict1
Pict2 the way it currently work _Wrong way.
Pict2
thanx .

 
Almosawi A.Mohammed

Re: I intend to buy, but some issues?

Reply #17
Hi Wilvin,

It is working perfectly when printing but when gerenating PDF, we´ve got the message below:

Warning: DOMDocumentFragment::appendXML(): Entity: line 6622: parser error : xmlParseEntityRef: no name in C:\xampp\htdocs\raiodesol\system\BaseView.php on line 744

Warning: DOMDocumentFragment::appendXML(): <span data-value="ELIAS DESOUZA & in C:\xampp\htdocs\raiodesol\system\BaseView.php on line 744

Can you help me to fix it?

Thanks!


Re: I intend to buy, but some issues?

Reply #19
Hi Wilvin!

I´ve found the error. Let me explain because it could be helpful for others developers:

I was trying to print a page with a custom view. I revised the HTML-Php code in the custom view and I found an error when closing an <a> tag. Apparently, when I see the page in the browser there was no error but when printing this error was propagated to the function that manipulates de DOM.

So, your recommendation above ran perfectly.

Thanks!!

Re: I intend to buy, but some issues?

Reply #20
Partially working. Now the error is disappeared, but the export is empty.

Re: I intend to buy, but some issues?

Reply #21
Please sir where to find report_layout.php?

Re: I intend to buy, but some issues?

Reply #22
I'm Brazilian, sorry for my English.

Problem solved for those who don't need Cyrillic characters.

In Functions.php add this:

Code: [Select]
function fixWrongUTF8Encoding($String) {
 $fix_accent_list = array(
     ''     => '&nbsp;',
     '>'    => '&gt;',
     '<'    => '&lt;',
     '&'    => '&amp;',
     '"'    => '&quot;'
 );
 
 
 //we get our accent characters and its utf-8 equivalent characters
 $error_chars = array_keys($fix_accent_list);
 $real_chars  = array_values($fix_accent_list);
 

 return str_replace($error_chars, $real_chars, $String);
}

In BaseView.php replace this

Code: [Select]
private function setInnerHTML($element, $html)
 {
 $html = htmlentities($html);
 $fragment = $element->ownerDocument->createDocumentFragment();
 $fragment->appendXML($html);
 $clone = $element->cloneNode(); // Get element copy without children
 $clone->appendChild($fragment);
 $element->parentNode->replaceChild($clone, $element);
 }

with this

Code: [Select]
private function setInnerHTML($element, $html)
     {
        
         $html = fixWrongUTF8Encoding($html);
         $html = html_entity_decode($html);
         $fragment = $element->ownerDocument->createDocumentFragment();
         $fragment->appendXML($html);
         $clone = $element->cloneNode(); // Get element copy without children
         $clone->appendChild($fragment);
         $element->parentNode->replaceChild($clone, $element);
     }

You don't need to change anything in the report_layout.php file.

I hope it helped you.

 

Re: I intend to buy, but some issues?

Reply #23
Thank you!


I'm Brazilian, sorry for my English.

Problem solved for those who don't need Cyrillic characters.

In Functions.php add this:

Code: [Select]
function fixWrongUTF8Encoding($String) {
 $fix_accent_list = array(
     ''     => '&nbsp;',
     '>'    => '&gt;',
     '<'    => '&lt;',
     '&'    => '&amp;',
     '"'    => '&quot;'
 );
 
 
 //we get our accent characters and its utf-8 equivalent characters
 $error_chars = array_keys($fix_accent_list);
 $real_chars  = array_values($fix_accent_list);
 

 return str_replace($error_chars, $real_chars, $String);
}

In BaseView.php replace this

Code: [Select]
private function setInnerHTML($element, $html)
 {
 $html = htmlentities($html);
 $fragment = $element->ownerDocument->createDocumentFragment();
 $fragment->appendXML($html);
 $clone = $element->cloneNode(); // Get element copy without children
 $clone->appendChild($fragment);
 $element->parentNode->replaceChild($clone, $element);
 }

with this

Code: [Select]
private function setInnerHTML($element, $html)
     {
        
         $html = fixWrongUTF8Encoding($html);
         $html = html_entity_decode($html);
         $fragment = $element->ownerDocument->createDocumentFragment();
         $fragment->appendXML($html);
         $clone = $element->cloneNode(); // Get element copy without children
         $clone->appendChild($fragment);
         $element->parentNode->replaceChild($clone, $element);
     }

You don't need to change anything in the report_layout.php file.

I hope it helped you.