mbintex author
There is a Javascript module to convert HTML to the format of PDFmake.js here https://github.com/Aymkdn/html-to-pdfmake I would need something similar, but for PHP. My current homebrew solution looks like this:
function HTMLconvert($html) {
return str_replace(
array("<p><img alt=\"\" src=\"data:image/png;base64,","\" /></p>",
"<p> </p>","<p>","</p>","<br />"," ",
"<ol>","</ol>",
"<ul>","</ul>",
"<li>","</li>",
"<i>","</i>",
"<em>","</em>",
"<b>","</b>",
"<strong>","</strong>",
"<u>","</u>",
"'"," ",
"Ä","Ö","Ü",
"ä","ö","ü","ß",
"€","<",">",
"&","§","²","³"),
array(
"']},{image: 'data:image/png;base64,",
"'},{text: ['",
"\\n\\n']},{style:'standard', text: [' ",
"",
"\\n']},{style:'standard', text: ['",
"\\n']},{style:'standard', text: ['",
"\\n']},{style:'standard', text: ['",
"']},{ol:[",
"]},{text: ['",
"']},{ul:[",
"]},{text: ['",
"'",
"',",
"',{text: '",
"', italics: true},'",
"',{text: '",
"', italics: true},'",
"',{text: '",
"', bold: true},'",
"',{text: '",
"', bold: true},'",
"',{text: '",
"', decoration: 'underline'},'",
"\"",
" ",
"Ä",
"Ö",
"Ü",
"ä",
"ö",
"ü",
"ss",
"Euro",
"<",
">",
"&",
"§",
"²",
"³"
),$html);
} But I guess the pros could do much better. Especially I have no solution for font sizes with varying sizes, font colors and inline styles like width and height for images. All spans are ignored too. Could anybody help?
|
|