I have this code where I get an element from my HTML and transform it in docx, but how could I add a footer to it? It should have a left text and the page count on the right. Don’t if this i made using CSS or it’s something i should add to the Head
export const Export2Doc = (element, filename = "") => {
// _html_ will be replace with custom html
const meta =
"Mime-Version: 1.0nContent-Base: " +
location.href +
'nContent-Type: Multipart/related; boundary="NEXT.ITEM-BOUNDARY";type="text/html"nn--NEXT.ITEM-BOUNDARYnContent-Type: text/html; charset="utf-8"nContent-Location: ' +
location.href +
"nn<!DOCTYPE html>n<html>n_html_</html>"
// _styles_ will be replaced with custome css
const head =
'<head>n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">n<style>n_styles_n</style>n</head>n'
// img {width:300px; border-radius: 12px;}
const css =
"<style>" +
"table {border-collapse: collapse; border-spacing: 0;} body {font-family: Arial, Helvetica, sans-serif;}" +
"</style>"
const { images, changedImages } = prepareImageData(element)
const imgMetaData = prepareImageMetaData(images)
const html = document.getElementById(element).innerHTML
const blob = new Blob(["uFEFF", html], {
type: "application/msword"
})
const output =
meta.replace("_html_", head.replace("_styles_", css) + html) +
imgMetaData
const url =
"data:application/vnd.ms-word;charset=utf-8," +
encodeURIComponent(output)
filename = filename ? filename + ".doc" : "document.doc"
const downloadLink = document.createElement("a")
document.body.appendChild(downloadLink)
if (navigator.msSaveOrOpenBlob) {
navigator.msSaveOrOpenBlob(blob, filename)
} else {
downloadLink.href = url
downloadLink.download = filename
downloadLink.click()
}
document.body.removeChild(downloadLink)
restoreImagesDimensions(changedImages, element)
}