Commit dd41c6a6 by ramdayalmunda

on pdf woff2 is not working used ttf file for fonts on PDF

parent ff45397b
...@@ -105,7 +105,6 @@ var ADocEditor = function (customConfig) { ...@@ -105,7 +105,6 @@ var ADocEditor = function (customConfig) {
<span class="option">Edit</span> <span class="option">Edit</span>
<span class="option">Insert</span> <span class="option">Insert</span>
<span class="option">Help</span> <span class="option">Help</span>
<span class="option" a-doc-editor-action="generate-pdf">PDF</span>
</div> </div>
<div class="option-bar"> <div class="option-bar">
<span class="option">Search</span> <span class="option">Search</span>
...@@ -148,7 +147,6 @@ var ADocEditor = function (customConfig) { ...@@ -148,7 +147,6 @@ var ADocEditor = function (customConfig) {
</div> </div>
</div> </div>
`; `;
console.log();
addFonts(["./assets/fonts/ArchitectsDaughter-Regular.woff2", "./assets/fonts/ArchitectsDaughter-Regular.ttf"], 'Architects Daughter') addFonts(["./assets/fonts/ArchitectsDaughter-Regular.woff2", "./assets/fonts/ArchitectsDaughter-Regular.ttf"], 'Architects Daughter')
addFonts(["./assets/fonts/calibri-regular.woff2", "./assets/fonts/calibri-regular.ttf"], 'Calibri') addFonts(["./assets/fonts/calibri-regular.woff2", "./assets/fonts/calibri-regular.ttf"], 'Calibri')
...@@ -208,8 +206,6 @@ var ADocEditor = function (customConfig) { ...@@ -208,8 +206,6 @@ var ADocEditor = function (customConfig) {
fontFamilyDropdown = document.getElementById(fontFamilyDropdownId) fontFamilyDropdown = document.getElementById(fontFamilyDropdownId)
fontFamilyDropdown.addEventListener('change', changeFontFamily) fontFamilyDropdown.addEventListener('change', changeFontFamily)
reRenderFontDropdown() reRenderFontDropdown()
let generatePDFBtn = document.querySelector('[a-doc-editor-action]')
generatePDFBtn.addEventListener('click', generatePDF)
} }
...@@ -712,8 +708,9 @@ var ADocEditor = function (customConfig) { ...@@ -712,8 +708,9 @@ var ADocEditor = function (customConfig) {
function embedFont(name) { function embedFont(name) {
return new Promise((res, rej) => { return new Promise((res, rej) => {
let fontObj = fontList.find(item => item.name == name) let fontObj = fontList.find(item => item.name == name)
console.log(fontObj) let url = fontObj.paths.find( item => item.slice(-4)=='.ttf' )
fetch(fontObj.paths[0]) if(!url) fontObj.paths[0]
fetch(url)
.then(async (data) => { .then(async (data) => {
let arrayBuffer = await data.arrayBuffer() let arrayBuffer = await data.arrayBuffer()
embededFonts[name] = await pdfDoc.embedFont(arrayBuffer) embededFonts[name] = await pdfDoc.embedFont(arrayBuffer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment