manumaticx / printmanager

Other
1 stars 3 forks source link

Error: Can print only from an activity #6

Open dethier1958 opened 3 years ago

dethier1958 commented 3 years ago

Perhaps I just need some actual sample code. Here's what I do:

var pm = require('de.manumaticx.printmanager'); var html = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'report.html');

html.write(report.studentProgressReport(stu)); pm.print({ title : 'Progress Report for Amy Albright', url : 'content://' + html.nativePath });

When I do this, I get the following error: Error: Can print only from an activity

Again, perhaps I just need a proper example of how to use this module.

dethier1958 commented 3 years ago

When I try to use your example, I get errors. The methods example and createExample do not exist.

Daniel Ethier

On Dec 8, 2020, at 1:30 AM, Manuel Lehner notifications@github.com wrote:

Hi, here is an example:

https://github.com/manumaticx/printmanager/blob/master/example/app.js https://github.com/manumaticx/printmanager/blob/master/example/app.js — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/manumaticx/printmanager/issues/6#issuecomment-740438655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQQRQH7L3WW3KDBS25QXZDSTXI2XANCNFSM4URFJHAA.

manumaticx commented 3 years ago

Hi, sorry. I removed the comment. This is a default module example which will of course not work. The only example I can give you is the one in the readme. But since this repository is very old, I guess it might not work anymore. If you happen to find a solution I really would like integrate it - PR very welcome. Unfortunately, I don't have the time anymore to investigate. Perhaps trying one of the forks could help, like https://github.com/AppWerft/printmanager

The only guess I can make when reading the error (Can print only from an activity) is that maybe an event listener to the window could be helpful (window.addEventListener('open', initPrinting);) - but I don't know in which context you are using it.

dethier1958 commented 3 years ago

Thanks. I actually tried something like your suggestion, but got the same error. I will keep trying some things and let you know if I have any luck.

Daniel Ethier

On Dec 8, 2020, at 2:42 PM, Manuel Lehner notifications@github.com wrote:

Hi, sorry. I removed the comment. This is a default module example which will of course not work. The only example I can give you is the one in the readme. But since this repository is very old, I guess it might not work anymore. If you happen to find a solution I really would like integrate it - PR very welcome. Unfortunately, I don't have the time anymore to investigate. Perhaps trying one of the forks could help, like https://github.com/AppWerft/printmanager https://github.com/AppWerft/printmanager The only guess I can make when reading the error (Can print only from an activity) is that maybe an event listener to the window could be helpful (window.addEventListener('open', initPrinting);) - but I don't know in which context you are using it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/manumaticx/printmanager/issues/6#issuecomment-740999032, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQQRQG76FE7P24MZLNWIC3ST2FU5ANCNFSM4URFJHAA.