Skip to content

How can I use custom font in Angular 6? #1984

@IngoManthey

Description

@IngoManthey

Hi,
For more than 6 weeks I try to install this in my Angular project. I started 2 attempts but did not get any further with both.
1.) I worte a default_vfs.js file with:
(function (jsPDFAPI) { "use strict"; jsPDFAPI.addFileToVFS('PTSans-Regular.ttf', base64 encoded ttffile); }
I save it in src/assests/js
My problem here with is unknown, how I integrate this file into Angular and how I must call these, so that the fonts are loaded.

2.) My 2 idea is to create a service that inserts the fonts into the document.
`import * as jsPDF from 'jspdf';

@Injectable()
export class JsPDFFontService {
AddFont(doc: jsPDF) {
doc.addFileToVFS('PTSans-Regular.ttf', base64);
}
}`
Here I unfortunately get the message "addFileToVFS is not present in the type jsPDF".

Can someone help me here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions