This documentation page https://www.phpdocx.com/documentation/cookbook/change-default-styles-import-HTML shows how to include inline styles in an HTML string, but is there a way to load an external stylesheet file to prepend the HTML string?
🏷️ Limited Offer: 25% OFF 🏷️
First 100 purchases only — Special discount!
Use this coupon on checkout: PHPDXPJ_D1SC1N5T
Get it nowThis documentation page https://www.phpdocx.com/documentation/cookbook/change-default-styles-import-HTML shows how to include inline styles in an HTML string, but is there a way to load an external stylesheet file to prepend the HTML string?
Hello,
We recommend you to check the examples available on https://www.phpdocx.com/documentation/introduction/html-to-word-PHP. You can apply CSS styles using style tags:
<head>
<style>
p {font-style: italic;}
p.header {font-size: 20px; font-weight: bold;}
div.footer {font-size: 10px;}
</style>
</head>external CSS files:
<head>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>and inline styles:
<tr>
<td style="background-color: #ffff00">Cell 1 1</td>
<td>Cell 1 2</td>
</tr>CSS styles must be applied each time embedHTML or replaceVariableByHTML are called.
UPDATE: HTML Extended (https://www.phpdocx.com/documentation/introduction/html-extended-to-word-PHP) , available in Premium licenses, includes addBaseCSS to set a base CSS used for all HTML conversions in the same script.
Regards.
Right, I'm already prepending a string containing inline style classes. Example:
$style = "<style>
p, span[style] {
font-family: Arial;
font-size: 7.5pt;
}
</style>";
I just thought phpdocx might provide a method for loading external stylesheets.
That said, I will simply roll my own solution for loading an external text file. Thanks.