Print Spooler has stopped in PrintManager

半城伤御伤魂 提交于 2019-12-11 05:19:55

问题


I am using PrintManager(when webview is loaded) as follow:

PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter(jobName));
printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());

When save button is clicked, HTML is saved as pdf. When this process is done very fast i.e. while preview is loading, getting the following exception "Unfortunately Print Spooler has stopped"

process: com.android.printspooler, PID: 5705
                                                 java.lang.IllegalArgumentException: end cannot be less than zero.
                                                     at android.print.PageRange.<init>(PageRange.java:50)
                                                     at com.android.printspooler.util.PageRangeUtils.asAbsoluteRange(PageRangeUtils.java:199)
                                                     at com.android.printspooler.ui.PrintActivity$DocumentTransformer.computePagesToShred(PrintActivity.java:2620)
                                                     at com.android.printspooler.ui.PrintActivity$DocumentTransformer.<init>(PrintActivity.java:2496)
                                                     at com.android.printspooler.ui.PrintActivity.transformDocumentAndFinish(PrintActivity.java:1733)
                                                     at com.android.printspooler.ui.PrintActivity.-wrap15(PrintActivity.java)
                                                     at com.android.printspooler.ui.PrintActivity$4.run(PrintActivity.java:620)
                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at android.os.Looper.loop(Looper.java:148)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Any suggestion to solve or catch this exception

来源:https://stackoverflow.com/questions/39391630/print-spooler-has-stopped-in-printmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!