Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using embedded fonts for client side generated files #2667

Open
xong opened this issue Apr 4, 2024 · 0 comments
Open

Using embedded fonts for client side generated files #2667

xong opened this issue Apr 4, 2024 · 0 comments

Comments

@xong
Copy link

xong commented Apr 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant