pedr0hug0 Posted May 21, 2015 Posted May 21, 2015 Helloi have a report build by parameters, with 3 colums and same value.After that, break page.I want print this report with X number of copies automatic.PS: cant loop the same document. i really need insert "number of copies" of this documents.Thanks
hozawa Posted May 21, 2015 Posted May 21, 2015 Unless you create your own tool with JasperReports library, the only solution I can think up is to put your report as three subreports.
pedr0hug0 Posted May 25, 2015 Author Posted May 25, 2015 SOLVED public void imprimir(String codigo, String tamanho, Integer qtd) throws JRException{ String arquivo = "relatorios_ireport/etiqueta_pausa.jasper"; //arquivo de relatorio java.io.InputStream file = getClass().getClassLoader().getResourceAsStream(arquivo); //carrego o arquivo //NUMERO DE REPETIÇÕES ArrayList array_qtd = new ArrayList(); //completar as 3 colunas com mesmo valor for(int i = 0; i < 3; i++){ array_qtd.add("Número" + i); } JRBeanCollectionDataSource dados_qtd = new JRBeanCollectionDataSource(array_qtd); Map parametros = new HashMap(); //parametro 1 (codigo) parametros.put("codigo", codigo); //parametro 2 (tamanho) parametros.put("tamanho", tamanho); //CRIANDO JasperPrint printer = null; printer = JasperFillManager.fillReport(file, parametros, dados_qtd); //exportar para pdf //JasperExportManager.exportReportToPdfFile(printer,"D://sample_report.pdf"); if (jCheckBox_visualizar.isSelected()){ //CHAMAR VIEW 1 DE CADA VEZ (FECHOU ABRE O OUTRO) JRViewer view = new JRViewer(printer); //preview JDialog dialog = new JDialog(); //jdialog que contem o preview dialog.getContentPane().add(view); //adiciono o preview dialog.setSize(600,300); dialog.setLocationRelativeTo(jPanel2); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setModal(true); dialog.setVisible(true); //CHAMAR VIEW DIRETO(TODOS AS QTD DE UMA VEZ) //JasperViewer.viewReport(printer, false); }else{ //PROBLEM SOLVED WITH EXPORTER ATRIBUTESET.ADD(NEW Copies(qtd)) qtd = number of copies i want :D PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); //printRequestAttributeSet.add(MediaSizeName.ISO_A4); printRequestAttributeSet.add(new Copies(qtd)); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); //printServiceAttributeSet.add(new PrinterName("Argox_OS-214_plus_series_PPLA", null)); //printServiceAttributeSet.add(new PrinterName("Argox OS-214 plus series PPLA em pcestamparia", Locale.getDefault())); printServiceAttributeSet.add(new PrinterName("Argox OS-214 plus series PPLA", Locale.getDefault())); //printServiceAttributeSet.add(new PrinterName("////pcestamparia//Argox OS-214 plus series PPLA", null)); //printServiceAttributeSet.add(new PrinterName("//pcestamparia/Argox OS-214 plus series PPLA", null)); //printServiceAttributeSet.add(new PrinterName("////pcestamparia//Argox_OS-214_plus_series_PPLA", Locale.getDefault())); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); exporter.setExporterInput(new SimpleExporterInput(printer)); SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration(); configuration.setPrintRequestAttributeSet(printRequestAttributeSet); configuration.setPrintServiceAttributeSet(printServiceAttributeSet); exporter.setConfiguration(configuration); //true para aprecer opções configuration.setDisplayPageDialog(false); configuration.setDisplayPrintDialog(false); exporter.setConfiguration(configuration); System.out.println("Inicializando impressão"); exporter.exportReport(); System.out.println("Impressão finalizada"); //IMPRIMIR DIRETO //JasperPrintManager.printReport(printer,false); } }//fim imprimir
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now