Dompdf UT8 with database records with accents - laravel

I have a problem with utf8 with my stored data with dompdf for laravel: https://github.com/barryvdh/laravel-dompdf
My column collation is set to
utf8mb4_unicode_ci
In my html file I use:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
So when I write in my html file : éééé and I generate the PDF it's file but when I display my stored data the accents are displayed by : ?
In my config/dompdf.php
I have set :
"DOMPDF_UNICODE_ENABLED" => true,
"DOMPDF_PDF_BACKEND" => "CPDF",
What am I doing wrong? The problem only come from my stored data.. Hope someone could help thanks a lot in advance.
When I display my blade page without dompdf on firefox it's also really strange I get spaces between the accents :
But with Chrome all is fine ..
Also when i trie to pass a variable with a accent to my dompdf view the content of the variable is not display when there is an accent
$fede = 'fé'; // not display
$fede = 'fe'; // is displayed as well..

I had same issue before , and i changed many things but i couldn't make it to work , then i switched to niklasravnsborg/laravel-pdf and it worked like sharm , give it a try and see

Related

I want a bootstrap cols css to be applied in laravel pdf

I am using Laravel inbuilt pdf to make PDF from the view but the view i made used bootstrap css but after converting the view in to pdf all bootstrap css is getting lost.
Below is my code
$data = [
'foo' => 'bar'
];
$pdf = PDF::loadView('leadmanagement.jobcard_operation_view', $data);
$pdf->SetProtection(['copy', 'print'], '', 'pass');
return $pdf->stream('JOB CARD.pdf');
Below is some screen shot of how my view looks and how my pdf looks
Image one is showing what type of view i actually need in my pdf
And How pdf Is Downloaded see below
Image 2nd Showing the view after pdf is being downloaded
Any help would be helpful
You need to import the bootstrap css into the pdf as well.
Also make sure you are setting
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
In the document head. Another possibility is if you use elixir, try
<link rel="stylesheet" href="{{ ltrim(elixir('assets/css/app.css'), '/') }}" />

Why are my search results not in the same charset as my page encoding?

I am using UTF-8 encoding for an html page.
<head>
<meta charset="utf-8">
In the debugger console, document.characterSet returns "UTF-8".
On the page, I have metadata (keywords, description, title) with a valid UTF-8 character: '®', which is UTF-8: 'c2ae'
The character displays correctly in the view source, and on the page title.
But google search results and bing search results are showing it as 'î'. That is, during the web crawl, it appears to be getting converted to ISO-8859-1 or Western-1252 displaying both bytes: 'c2' and 'ae'.
If I replace the character with ® => (\u00ae) it shows correctly.
Short of converting my meta data to ISO-8859-1, is there a best practice I should be using for this?
Issue was on the back-end, the data was not being transcoded to UTF-8 properly when read from cache. So, I feel the best practice is to use the native UTF-8 BMP character, with the proper page encoding, and not be required to use html entity values.
Look at the pages meta tags and confirm that it is not using this:
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
For HTML5 Google recommends:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Also note this:
Note:
<meta charset="">
Another Note:
Some characters are reserved in HTML. "Html Entities"
These reserved characters in HTML must be replaced with character entities.
e.g.
& ampersand & &
® registered trademark ® ®

Insert HTML codes in CKEditor textarea

I would like to know if there is a plugin in order to insert HTML codes in a CKEditor textarea?
I tried to install the PBCKCode plugin but it doens't work because the HTML is executed in my textarea.
Anthony
EDIT1 ----- INSERTPRE Plugin -------
Query when I add the post :
INSERT INTO `Posts` (`slug`,`title`,`thumbnail`,`content`,`tags`,`state`,`click`,`createdAt`,`updatedAt`,`id`) VALUES ('dsq','dsq','http://4.bp.blogspot.com/-knCgLUMOkJc/TeMY2jkmACI/AAAAAAAAAV0/VByHmoMa2N8/s1600/first+blog+posting.jpg','<pre class="prettyprint">\r\n<div>toto</div></pre>\r\n\r\n<p>dqsdqs</p>\r\n','toto','0',0,'2013-04-30 12:15:46','2013-04-30 12:15:46',NULL);
The result in my textarea when I try to edit the post :
<pre class="prettyprint">
</pre>
<div>toto</div>
<p>dqsdqs</p>
As you can see the "div" have changed of place.
EDIT2 ----- Escape HTML -------
Screenshot : http://grab.by/m8bs
As you can see it works in a P tag (just above the slug) but it doesn't work in my textarea. I think CKEditor encode my content but I don't know when and why... In my database everything is ok, I have the codes into the PRE tag.
Check these two plugins:
http://ckeditor.com/addon/insertpre
http://ckeditor.com/addon/syntaxhighlight
We use the first one on http://ckeditor.com/forum and it works very well.
Update: That's because you're not encoding HTML before you pass it to textarea. Use htmlspecialchars (or other similar function if you're not using PHP) to do that.
Update2: You are doing something wrong, but I don't know on what stage. The output data (editor.getData()) from the editor with one <pre> element is:
<pre class="prettyprint"><div></pre>
See that <pre> is not encoded, but <div> inside it is. Your examples show me that you "flattened" that structure - you have encoded both things equally when it should be:
<pre class="prettyprint">&lt;div&gt;</pre>
Note: &lt; is an encoded <.
You can use source menu in ck editor header to add your html
Use this tutorial
demo link
Okay Try This
for added Post
addslashes($_POST['post_from_textarea']);
to Edit
stripslashes($yourvairablegetRowsQuery)

Why codeigniter display double quote(empty) on top page

I use codeigniter framework, run on chrome but display double quote on top page.
My controller call view page.
public function index(){
$this->load->view('dash_main');
}
dash_main.php
<html>
<head>
<title>test</title>
</head>
<body>
Hello World
</body>
</html>
How can i edit?
Those aren't in your source code, it's just what the Chrome inspector shows around text. Nothing to do with Codeigniter, nothing to do with your code or HTML output.
View the actual page source and you won't see any quotes (but you will see a lot of white space judging from your screen shot).
Make sure that your file (view) has been saved to UTF-8 format.
I got the same problem as you, just change file to utf-8 format. that's all ^^

Validating custom tumblr theme

I am witing a custom tumblr theme. When I went to validate it using the W3C validator I got a bucket full of errors from the code tumblr inserts into the blog outside of my theme code. So I did troubleshooting 101 and installed their default theme and tried to validate it. I used the Redux theme. When I put it into the validator I get these 3 errors:
Line 2, Column 871: Stray doctype.
….0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Error Line 3, Column 67: Stray end tag html.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Error Line 3, Column 67: Cannot recover after last error. Any further errors will be ignored.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
so my question, how critical is validation? The problem I'm trying to solve is that my custom theme is quite sluggish. I figured step 1 to speed it up would be use valid markup. But that does not seem possible. (Also getting buckets of errors from the FB G+ and TW button code that I have no control over). thanks in advance.
I believe the problem with trying to validate a Tumblr theme is that there is specific code that Tumblr recognises, and needs, that an HTML validator will count as invalid. Although it is used in Tumblr, it is technically not correct as just html.
Code for blog posts such as
{block:Label}
may be flagged as invalid as the HTML validator doesn't know that it as correctly structured code for Tumblr. The validator may say that it is invalid when placed in a certain context such as in 'li' elements even though for Tumblr this is where it is meant to be placed.
Try using this validator as you can group errors by type, that way you can see if you have errors other than ones created by using Tumblr code.
http://validator.keegan.st/
Solve all the html errors and don't worry about the tumblr caused ones.

Resources