Hi Team,
I am trying following simple html file with external css to convert it to pdf.
It is getting converted but css is not getting loaded.
This is my conversion script.
var api = require(‘@asposecloud/aspose-html-cloud’);
// Create Conversion Api object
var conversionApi = new api.ConversionApi(conf);
var src = “./htmlstyle.html”; // {String} Source document.
var dst = “./teststyle.pdf”; // {String} Result document.
var opts = null;
var callback = function (error, data, response) {
if (error) {
console.error(error);
} else {
console.log(data);
}
};
conversionApi.convertLocalToLocal(src, dst, opts, callback);
Following is the html I am trying
var api = require(‘@asposecloud/aspose-html-cloud’);
// Create Conversion Api object
var conversionApi = new api.ConversionApi(conf);
var src = “./htmlstyle.html”; // {String} Source document.
var dst = “./teststyle.pdf”; // {String} Result document.
var opts = null;
var callback = function (error, data, response) {
if (error) {
console.error(error);
} else {
console.log(data);
}
};
conversionApi.convertLocalToLocal(src, dst, opts, callback);
CSS file:
/* General styling for the entire document */
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
color: #333;
background-color: #f9f9f9;
}
/* Styling the header */
header h1 {
text-align: center;
color: #2c3e50;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
}
/* Invoice details section */
.invoice-details {
background-color: #ecf0f1;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
/* Styling the table */
.styled-table {
width: 100%;
border-collapse: collapse;
}
.styled-table th,
.styled-table td {
border: 1px solid #3498db;
padding: 10px;
text-align: left;
}
.styled-table th {
background-color: #3498db;
color: #fff;
}
.styled-table tbody tr:nth-child(even) {
background-color: #f2f2f2;
}
/* Footer styling */
footer {
text-align: center;
margin-top: 30px;
font-weight: bold;
color: #27ae60;
}