So I did some checks. I have two js files main.js
and myfile.js
. Electron runs the main.js
in start (as usual) and also opens the actual app window which (i.e. the renderer process) runs the myfile.js
. Now it turns out If I put
const orca = require('orca/src')
const fs = require('fs')
const app = orca.run({
component: 'plotly-graph',
input: JSON.stringify({
figure: {
data: [{y: [2, 1, 2]}],
layout: {title: {text: 'My graph'}}
},
format: 'pdf',
width: 800,
height: 500
}),
debug: process.env.DEBUG
})
app.on('after-export', (info) => {
fs.writeFile('out.pdf', info.body, (err) => { if(err) console.warn(err) })
})
// other available events:
app.on('after-export-all', () => {})
app.on('export-error', (info) => console.warn(info.msg))
app.on('renderer-error', (info) => console.warn(info.msg))
this part of the code directly in main.js
then electron opens the window, outputs the output.pdf
closes the window quickly.
If I put the code in myfile.js
(i.e in renderer process) it doesn’t work throws the prvious error.
If I keep the part of the code (in a function) in the index.js
and calls the function from the renderer process using ipcRenderer.send
it doesn’t gives any output but also doesn’t throws any error.
So, I need keep that code block in main process because it doesn’t work in renderer process, also I can’t run this using inter processes communication calls. So, how do I do it? Am I doing something wrong?