I am using the print js library to export tables in my application. I need to put a header when exporting each page. Now when I use the json type as follows
let someJSONdata = [{
name: 'name',
email: "fda@daa.com",
phone: "46228156"
}];
let url = 'urlstring';
let rawHTML = `
<div id="header">
<img src="${url}" alt="">
<div class="parraf">
<h3 style="margin:0px"> title </h3>
<h5 style="margin:0px"> subtitle </h5>
<h6 style="margin:0px"> description </h6>
</div>
</div> <br>`;
printJS({
printable: someJSONdata,
type: 'json',
properties: ['name', 'email', 'phone'],
header: rawHTML,
style: '#header { display: flex; } #header img { max-width: 120px;} .parraf { width: 100%; padding: 0px; text-align: center; max-height: 80px }'
});
** This works well. The thing is that for my situation I am exporting directly to html so the code would look like this: **
let url = 'pathhere';
let rawHTML = `
<div id="div_toexport_from_html">
<img src="${url}" alt="">
<div class="textos">
<h3 style="margin:0px"> INSTITUTO TECNOLOGICO DE SONORA </h3>
<h5 style="margin:0px"> ADMINISTRACION DE PERSONAL </h5>
<h6 style="margin:0px"> Reporte de permisos </h6>
</div>
</div> <br>`;
printJS({
printable: 'div_toexport_from_html',
type: 'html',
header: rawHTML,
style: '#div_toexport_from_html { display: flex; } #div_toexport_from_html img { max-width: 120px;} .textos { width: 100%; padding: 0px; text-align: center; max-height: 80px; color: #0b6db5; } ',
targetStyles: ['*'],
maxWidth: setMaxWidth,
ignoreElements: viewtoIgnore
});
the bad thing is that it does not correctly rander the html but takes it as a normal text string. Could it be possible or in what way can it be operated this way?
In summary The route in this case I put it as a reference that the real url would be placed there. The issue is that I don't know if the printjs library in the options to export allows the following:
var printTypes = ['pdf', 'html', 'image', 'json', 'raw-html'];
When using the
type = 'json'
correctly rander the header that is passed through a raw-html string. However, when using the
type = 'html'
which is my case, it does not correctly rander the specified raw-html string since it takes it as if it were a normal text.
Maybe that way the library works. Who knows?