Using embedded fonts for client side generated files
xong opened this issue · comments
Robert Rupf commented
Hi,
I am trying to embed custom fonts.
The docx-file ist generated at the client browser.
Please consider following example:
// create document0
import {Document, Packer} from "docx";
// base64 encoded demo/assets/Pacifico.ttf (Insert by yourself since it would burst this comment.)
const font = atob('...');
const doc = new Document({
sections: [],
fonts: [{ name: 'Pacifico', data: font }], // this is the error causing line
});
Packer.toBlob(doc).then((blob) => {
let a = document.createElement('a');
a.href = window.URL.createObjectURL(blob);
a.download = 'example.docx';
a.click();
});
I get following error message for index.mjs:18833
:
Uncaught (in promise) TypeError: bytesToObfuscate.map is not a function
Is there any way to embed custom fonts for client side use?
Your help will be very much appreciated.
Robert