DsPdfViewer custom font family support

window.onload = function(){ //DsPdfViewer.LicenseKey = "***key***"; const viewer = new DsPdfViewer("#viewer", { workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js", supportApi: { apiUrl: window.top.SUPPORTAPI_URL, token: window.top.SUPPORTAPI_TOKEN, webSocketUrl: false }, restoreViewStateOnLoad: false }); viewer.addDefaultPanels(); viewer.addAnnotationEditorPanel(); viewer.toolbarLayout.viewer = { default: ["save", "zoom", "about"], mobile: ["save", "zoom", "about"], fullscreen: ["$fullscreen", "save", "zoom", "about"] }; viewer.toolbarLayout.annotationEditor = { default: ["edit-select", "$split", "edit-free-text", "$split", "edit-undo", "edit-redo", "save"], mobile: ["edit-select", "$split", "edit-free-text", "$split", "edit-undo", "edit-redo", "save"], fullscreen: ["$fullscreen", "edit-select", "$split", "edit-free-text", "$split", "edit-undo", "edit-redo", "save"] }; viewer.applyToolbarLayout(); viewer.options.editorDefaults.freeTextAnnotation = { fontName: 'FantaisieArtistique', borderStyle: { width: 0 } }; viewer.options.editorDefaults.fontNames = [ { name: 'Disco font', value: 'BudmoJiggler-Regular' }, { name: 'Fantaisie font', value: 'FantaisieArtistique' } ]; viewer.newDocument().then(async function() { await viewer.addAnnotation(0, { annotationType: 3, // AnnotationTypeCode.FREETEXT borderStyle: { width: 0 }, appearanceColor: "#ff1493", fontName: "BudmoJiggler-Regular", fontSize: 74, contents: "DISCO MUSIC", textAlignment: 1, rect: [0, 680, 612, 782], convertToContent: true } ); await viewer.addAnnotation(0, { annotationType: 3, // AnnotationTypeCode.FREETEXT borderStyle: { width: 0 }, appearanceColor: "#00bcd4", fontName: "FantaisieArtistique", fontSize: 46, contents: "Disco Music ignites\ncity nights,\na magic spell\nthat syncs hearts and bodies.\nMirror ball's gleam fuels energy waves, filling air with joy.\nWear dance shoes, embrace light and sound –\ndisco's timeless.", textAlignment: 1, rect: [56, 50, 556, 680], convertToContent: true }); viewer.zoom = { mode: 1 }; }); }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Custom FreeText font family support</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./src/styles.css"> <script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.js"></script> <script src="/document-solutions/javascript-pdf-viewer/demos/resource/js/init.js"></script> <script src="./src/app.js"></script> <link rel="preload" href="/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/fonts/budmo_jiggler.ttf" as="font" type="truetype" crossorigin> <link rel="preload" href="/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/fonts/FantaisieArtistique.ttf" as="font" type="truetype" crossorigin> <style> @font-face { font-family: BudmoJiggler-Regular; src: url(/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/fonts/budmo_jiggler.ttf) format('truetype'); } @font-face { font-family: FantaisieArtistique; src: url(/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/fonts/FantaisieArtistique.ttf) format('truetype'); } </style> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }