带有spring MVC的JasperReport:在客户端打印报告而不显示它(JasperReport with spring MVC : print report on client side without displaying it)
我正在开发一个Spring MVC - Angularjs应用程序。
我需要打印报告,我选择了JasperReport来做到这一点。在我继续之前,我想知道我是否可以生成报告,然后将其直接打印在客户端计算机上设置的默认打印机(可根据用户更改的打印机) 上 , 而不在屏幕上显示。
我一直在寻找这个特定需求的答案,但找不到任何答案。如果有人知道它....
生成报告并打印它的来源:
HashMap<String, Object> params = new HashMap<String, Object>(); params.put("Title", "My Report"); InputStream reportStream = this.getClass().getResourceAsStream(TEMPLATE); JasperDesign jd = JRXmlLoader.load(reportStream); JasperReport jr = JasperCompileManager.compileReport(jd); JasperPrint jp = JasperFillManager.fillReport(jr, params, datasource.getDataSource()); JasperPrintManager.printReport(jp, false);
I am developping a Spring MVC - Angularjs application.
I need to print reports, I chose JasperReport to do that.Before I move on, I want to know if I can generate a report, then directly print it on the default printer set up on the client computer (printer which can change according to users) without displaying it on screen.
I have been looking for answers on this specific need, but couldn't find any.If anyone knows about it....
Source to generate report and print it:
HashMap<String, Object> params = new HashMap<String, Object>(); params.put("Title", "My Report"); InputStream reportStream = this.getClass().getResourceAsStream(TEMPLATE); JasperDesign jd = JRXmlLoader.load(reportStream); JasperReport jr = JasperCompileManager.compileReport(jd); JasperPrint jp = JasperFillManager.fillReport(jr, params, datasource.getDataSource()); JasperPrintManager.printReport(jp, false);
原文:https://stackoverflow.com/questions/28961181
最满意答案
- 将导航控制器嵌入到故事板的第一个视图中
然后尝试使用此代码: -
@IBAction func signUpComplete(_ sender: Any) { if self.signUpEmailField.text == "" || self.signUpPasswordField.text == "" { let alert = UIAlertController(title: "Oops!", message: "A valid E-mail and Password are Required", preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil) }else{ FIRAuth.auth()?.createUser(withEmail: self.signUpEmailField!.text, password: self.signUpPasswordField!.text, completion: { (user, err) in if let ErrorCode = FIRAuthErrorCode(rawValue: err!._code){ switch ErrorCode { case .errorCodeEmailAlreadyInUse : let emailExists = UIAlertController(title: "Oops!", message: "A user with this E-Mail already exists!", preferredStyle: UIAlertControllerStyle.alert) emailExists.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil)) self.present(emailExists, animated: true, completion: nil) break default : break } }else{ let nextView = self.navigationController!.storyboard!.instantiateViewController(withIdentifier: "signUpSucceededSegue") self.navigationController!.pushViewController(nextView, animated: true) } }) } }
然后以类似的方式更改您的其他代码块。
- Embed a Navigation Controller to the very first view of your storyboard
Then Try using this code:-
@IBAction func signUpComplete(_ sender: Any) { if self.signUpEmailField.text == "" || self.signUpPasswordField.text == "" { let alert = UIAlertController(title: "Oops!", message: "A valid E-mail and Password are Required", preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil) }else{ FIRAuth.auth()?.createUser(withEmail: self.signUpEmailField!.text, password: self.signUpPasswordField!.text, completion: { (user, err) in if let ErrorCode = FIRAuthErrorCode(rawValue: err!._code){ switch ErrorCode { case .errorCodeEmailAlreadyInUse : let emailExists = UIAlertController(title: "Oops!", message: "A user with this E-Mail already exists!", preferredStyle: UIAlertControllerStyle.alert) emailExists.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil)) self.present(emailExists, animated: true, completion: nil) break default : break } }else{ let nextView = self.navigationController!.storyboard!.instantiateViewController(withIdentifier: "signUpSucceededSegue") self.navigationController!.pushViewController(nextView, animated: true) } }) } }
Then alter your other code-block in the similar fashion.
相关问答
更多-
Firebase注册Swift(Firebase sign up with Swift)[2022-05-01]
只要没有错误, FIRAuth.auth()?.createUserWithEmail将立即创建用户,那么就不需要 // Create Firebase User let userData = ["provider" : "email", "password": password!] DataService.ds.createFirebaseUser(user!.uid, user: userData) print("firebase user created!") self.loginUser() 检查 ... -
Firebase身份验证未被调用并返回空用户(Swift)(Firebase authentication not being called and returns a null user (Swift))[2022-04-26]
问题是signIn是异步函数,需要一些时间来执行。 这意味着当你调用你的logIn函数时,在signIn能够让你登录之前,你的else { return nil}执行,返回的值是零。 你不应该从这个函数返回,你应该做的是使用回调函数:所以用这个替换你的函数头。 func logIn(email: String,password: String, callback: @escaping (Firebase.User?) -> ()) { if在函数中删除最后一个,因为您不需要它,所有内容都将在signIn块中 ... -
Firebase授权(Firebase Authorization)[2023-07-05]
Firebase几乎可以处理所有内容,以下是他们提供的错误列表,您可以使用: https : //firebase.google.com/docs/auth/ios/errors#method_specific_error_codes 或者您可以像这里一样显示NSLocalizedDescription : FIRAuth.auth()?.signIn(withEmail: email, password: password) { (user, error) in if let error ... -
Swift Firebase在创建新用户时表示内部错误(Swift Firebase says internal error when creating a new user)[2022-02-27]
在Podfile中包含以下pod: pod'Firebase / Auth' 打开身份验证部分并启用电子邮件/密码登录方法并保存。 确保在项目中添加了GoogleService-Info.plist文件。 在Appdelegate: - import Firebase func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOpti ... -
将用户对象传递给函数: createTreeForNewUser({ uid: 'xxx', displayName: 'John', email: 'foo@bar.com', photoURL: 'https://...', metadata: {creationTime: 123} }) Pass the user object to the function: createTreeForNewUser({ uid: 'xxx', displa ...
-
未执行Firebase登录(Firebase signout not performed)[2022-08-29]
如果有人遇到同样的问题,我就是这样解决的: 问题来自我从异步任务(在user.updateProfile(profile)完成时) user.updateProfile(profile)的user.updateProfile(profile) 。 我写了一个错误, else if(mFinished)不检查user == null 。 这导致了一些我没有退出而返回到LoginActivity情况。 In case someone faces the same problem once, here is ho ... -
使用firebase未执行创建新用户后发现-Swift(Segue after new user creation using firebase not being performed -Swift)[2023-09-08]
将导航控制器嵌入到故事板的第一个视图中 然后尝试使用此代码: - @IBAction func signUpComplete(_ sender: Any) { if self.signUpEmailField.text == "" || self.signUpPasswordField.text == "" { let alert = UIAlertController(title: "Oops!", message: "A valid E-mail and Password are Requ ... -
你只需要在你的Dictionary使用subscript 。 同样在Swift中使用Dictionary而不是NSDictionary 。 let queryRef = FIRDatabase.database().reference().child("users") queryRef.child(FIRAuth.auth()!.currentUser!.uid).observe(.value, with: { (snapshot) -> Void in if let dictionary = s ...
-
我正在调查同样的事情。 我的问题是我也希望启用持久性,所以我需要知道可以脱机访问的内容。 如果您正在使用持久性,我还建议不允许特定操作,例如在您的客户端离线时检查用户名是否存在,您可以通过收听“.info / connected”来执行此操作,如下所述: https://firebase.google.com/docs/database/ios/offline-capabilities#section-connection-state 我的个人工作流程如下: 登录用户的帐户 检查用户是否已拥有用户名 检查f ...
-
iOS Swift以编程方式在Firebase实时数据库中创建子项(iOS Swift Create Child in Firebase Realtime Database Programatically)[2022-03-30]
执行FIRAuth.auth()?.createUser ,可以检查错误是否为零。 如果不是,那么您知道用户已创建,因此可以添加您的新孩子。 你可以这样写: let uid: String = (FIRAuth.auth()?.currentUser?.uid)! FIRDatabase.database().reference().child(uid).setValue(//an array of data that you want to store) 因此,您创建的新节点是用户的Firebase I ...