Используйте инструменты, аналогичные https://sphilee.github.io/jsPDF-CustomFonts-support/ или см. Пример кода.
window.loadedFile;
window.loadedFileContents;
var opts = {
on: {
load: function(e, file) {
window.loadedFile = file;
document.getElementById('fontName').value = file.extra.nameNoExtension;
var fileReader = new FileReader();
fileReader.onload = function(e) {
window.loadedFileContents = e.target.result;
window.loadedFileContents = window.loadedFileContents.substr(
window.loadedFileContents.indexOf('base64,') + 7
);
};
fileReader.readAsDataURL(file);
}
}
};
FileReaderJS.setupInput(document.getElementById('file-input'), opts);
var createFile = document.getElementById('createFile');
createFile.addEventListener('click', generateJsPDFFontFile, false);
function generateJsPDFFontFile() {
var jsFile = '';
var fontName = document.getElementById('fontName').value;
var fontStyle = document.getElementById('fontStyle').value;
var createdFileName = fontName + '-' + fontStyle + '.ttf';
var font = window.loadedFileContents;
var doc = new jsPDF();
doc.addFileToVFS(createdFileName, font);
doc.addFont(createdFileName, fontName, fontStyle);
doc.setFont(fontName);
doc.text(15, 15, document.querySelector('[name="content"]').value || 'Привет, Мир!');
doc.save('test.pdf');
}
<script src="http://bgrins.github.io/filereader.js/filereader.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
<form id="file-form" method="post" class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="fontName">fontName</label>
<input type="text" name="fontName" id="fontName" placeholder="fontName" />
</div>
<div class="pure-control-group">
<label for="fontStyle">fontStyle</label>
<select name="fontStyle" id="fontStyle">
<option value="normal">normal</option>
<option value="bold">bold</option>
<option value="italic">italic</option>
<option value="bolditalic">bolditalic</option>
</select>
</div>
<div class="pure-control-group">
<label for="name">File</label>
<input type="hidden" name="extra-data" multiple />
<input type="file" id="file-input" name="file-input" multiple />
</div>
<div class="pure-control-group">
<label for="content">Content</label>
<input type="text" name="content">
</div>
<div class="pure-controls">
<button value="Create" id="createFile" class="pure-button pure-button-primary">
Create
</button>
</div>
</fieldset>
</form>