-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing PDF programatically #21
Comments
@patrickrobbins
|
How do I close the hidden window? |
@ram-you solution really works! But we have to make something before, because it seems it can't print until PDF gets render (and that has sense). This is what I got:
And about @wujingshi question:
I found a good post here How to detect window.print() finish.
This is the way I used it on my Electron application and until now is working nice. Finally it would be nice if this module could improve and handle those events for us. Greets. |
If you are interested on print direct and don't even show the window, this did the trick for me: const PDFWindow = require('electron-pdf-window')
const win = new BrowserWindow({ show: false })
PDFWindow.addSupport(win)
win.loadURL('file://PATH_TO_FILE.pdf')
win.webContents.on('did-finish-load', () => {
setTimeout(() => {
win.webContents.print(options || {}, (success) => {
if (success) {
console.log('Finished printing with success')
} else {
console.error('Finished printing with error')
}
win.close()
})
}, 2000) // A time to load and render PDF
}) |
This prints a blank page for me. It seems like webContents is blank when you use PDF? How did you get it to work? |
Sorry, this plug-in is not perfect. I've abandoned it. |
Sure I'll wait. Let me know when you do. |
@wujingshi any updates ? Please provide link for your plugin , Thanks ! |
@arslanmughal99 |
@wujingshi if you can push repo on github maybe i can help fixing . Also are you facing error on macOs ? |
By the way i fix me issue using Sumatra PDF . |
@arslanmughal99 |
I didn't encounter the first issue you have mentioned , but as for packaging issue it is totally possible simple add binary in your |
@arslanmughal99 |
3.2 64bit-build |
I would like to load a PDF in a hidden window, and then programmaticly send this to the printer without any interaction from the user. (The use would click the print button on my app's view)
I'm not sure what the object is that I should be interacting with in the PDFWindow that would give me access to the pdf.js PDFPrintService.
Thanks
The text was updated successfully, but these errors were encountered: