/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperPrintManager;

/**
 *
 * @author IAGO
 */
public class JavaPrinter 
{
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        try
        {
            System.out.println("Imprimindo...");
            
            Connection conn1 = connection.GetConnection();
            
            Map map = new HashMap();
            map.put("HASH", args[0]);
            map.put("CON_ITENS", conn1);
            
            String arquivoJasper = "jasper/printer.jasper";
                    
            JasperPrint rel = JasperFillManager.fillReport(arquivoJasper, map, connection.GetConnection());  
            int finalPag = rel.getPages().size() - 1;  
            JasperPrintManager.printPages(rel, 0 , finalPag ,false);
            
            System.out.println("Pronto!");
        }
        catch(JRException e)
        {
            System.out.println("Erro: "+e.toString());
            e.printStackTrace();
        }
    }    
}
