How to remove HTML tags in PDF?

How to remove HTML tags?

I want to remove HTML tags in a PDF view. Take a look at the image below. Please help me with this.

This is my code:

$string1 = $_POST["editor1"]; $string1 = str_replace("<p>", "", $string1); $string2 = str_replace("&nbsp; ", " ", $string1); $string2 = explode("</p>", $string1); 

This is my conclusion:

 foreach ($string2 as $key) { $pdf->Multicell(0,3,$key); } ?> 

my pdf file

+7
html php pdf
source share
3 answers

The strip_tags() function breaks a string into HTML, XML, and PHP tags.

strip_tags(string,allow)

$string1 = strip_tags($string1);

* Update

-Getting specific tags for printing. A.

echo strip_tags("Hello <b><i>SO!</i></b>","<b>");

prints Hello SO!

+7
source share

You can use the following code to replace special characters in pdf format. I used this code in my java project and it works great. I changed this to php for you.

  $string1=str_replace("&nbsp", " ", $string1 ); $string1=str_replace("&", "&amp;", $string1 ); $string1=str_replace(">", "&gt;", $string1 ); $string1=str_replace("<", "&lt;", $string1 ); $string1=str_replace("&agrave;", "&#192;", $string1 ); $string1=str_replace("&euml;", "&#203;", $string1 ); $string1=str_replace("\"", "&quot;", $string1 ); $string1=str_replace("&lt;br /&gt;", "<br />", $string1 ); $string1=str_replace("&eacute;", "&#233;", $string1 ); $string1=str_replace("à", "&#224;", $string1 ); 
+3
source share

strip_tags () is the best way. str_replace () requires more code.

0
source share

All Articles