Commit 65736c13 by ramdayalmunda

genereate PDF fixes

parent 6681a6d0
...@@ -89,6 +89,7 @@ var ADocEditor = function (customConfig) { ...@@ -89,6 +89,7 @@ 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>
...@@ -145,6 +146,9 @@ var ADocEditor = function (customConfig) { ...@@ -145,6 +146,9 @@ var ADocEditor = function (customConfig) {
rightSidebar.classList.toggle('hide') rightSidebar.classList.toggle('hide')
}) })
let generatePDFBtn = document.querySelector('[a-doc-editor-action]')
generatePDFBtn.addEventListener( 'click', generatePDF)
reRenderPages(dataSet) reRenderPages(dataSet)
} }
...@@ -606,6 +610,14 @@ var ADocEditor = function (customConfig) { ...@@ -606,6 +610,14 @@ var ADocEditor = function (customConfig) {
} }
} }
function generatePDF(e){
if (isModule){
console.log('to generate PDF on Server side')
}else{
console.log('to generate PDF on browser')
}
}
inititalize(customConfig) inititalize(customConfig)
...@@ -620,10 +632,12 @@ var ADocEditor = function (customConfig) { ...@@ -620,10 +632,12 @@ var ADocEditor = function (customConfig) {
reRenderPages(dataSet) reRenderPages(dataSet)
caretData.activeData = null caretData.activeData = null
caretData.activeData = dataSet[0] caretData.activeData = dataSet[0]
caretData.index = 0
}, },
getContent: function () { getContent: function () {
return JSON.parse(JSON.stringify(dataSet)) return JSON.parse(JSON.stringify(dataSet))
} },
generatePDF,
} }
return returnObj return returnObj
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<p>Click on the canvas and start typing <p>Click on the canvas and start typing
<button onclick="extractData()">Extract</button> <button onclick="extractData()">Extract</button>
<button onclick="setData()">Set Data</button> <button onclick="setData()">Set Data</button>
<button onclick="generatePDF()">Generate PDF</button>
</p> </p>
<div id="user-container-for-editor"></div> <div id="user-container-for-editor"></div>
......
let ADocEditor = require("./a-doc-editor-node.js")
module.exports = async function(req, res){
try{
console.log('reaching server', )
let editor = new ADocEditor()
console.log('editor', editor)
res.status(200).json( { success: true, message: "Successfull" } )
}catch(err){
console.log(err)
res.status(200).json({ message: "Failed" })
}
}
\ No newline at end of file
const express = require("express") const express = require("express")
const port = 3910; const port = 3910;
const path = require("path") const path = require("path");
const app = express() const app = express()
app.use( express.json() )
app.post( '/generate-pdf', require("./generate-pdf") )
app.use( express.static( path.join( __dirname, 'dist' ) ) ) app.use( express.static( path.join( __dirname, 'dist' ) ) )
app.listen( port, ()=>{ app.listen( port, ()=>{
console.log(`Doc Editor on http://localhost:${port}`) console.log(`Doc Editor on http://localhost:${port}`)
} ) } )
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"express": "^4.18.2" "canvas": "^2.11.2",
"express": "^4.18.2",
"jspdf": "^2.5.1"
} }
} }
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