Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static void exportToPdf(){
  2. String s = MethodHandles.lookup().lookupClass().getSimpleName()+"_export";
  3. if(!Application.authorize(s)){
  4. render("errors/401.html");
  5. }
  6. String username = Security.connected();
  7. try {
  8. JasperPrint jp = JasperFillManager.fillReport(
  9. Fakture.class.getResource("/izvestaj/test.jasper").openStream(),
  10. null, DriverManager.getConnection("jdbc:mysql://localhost/poslovna?autoReconnect=true&useSSL=false","root","viktor12345"));
  11. File pdf = File.createTempFile("output.", ".pdf");
  12. JasperExportManager.exportReportToPdfStream(jp, new FileOutputStream(pdf));
  13. CustomUtilClass.logToFile(username, "Object = FAKTURA - EXPORTED TO PDF", null, "--==EXPORT TO PDF==--");
  14. System.out.println(pdf);
  15. }catch (Exception ex) {
  16. ex.printStackTrace();
  17. CustomUtilClass.logErrorToFile(username, "Object = FAKTURA COULD NOT BE EXPORETED TO PDF", null, "--==EXPORT TO PDF ERROR!!!==--");
  18. }
  19.  
  20. show("edit");
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement