Issue with Java print and Jasper report

I am using Java print with Jasper to print reports. I have designed a report in A5 size but when I print using Java Print API the size is diminished when I set the print media to A5, and out of scale when I set print media to A4. How would it be possible to specify size of print job in a manner that Java Print API would take the reports specified size?

Here is my code :

JasperPrint jasperPrint = null; try { InputStream inputStream = new FileInputStream(jrxmlFile); JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource( dataBeanList); /* * this portion of code is only required if you want to compile on * the fly */ jasperPrint = JasperFillManager.fillReport(inputStream, parameters, beanColDataSource); } catch (Exception e) { e.printStackTrace(); throw new Exception(e); } long start = System.currentTimeMillis(); PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(mediaSizeName); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); // printServiceAttributeSet.add(new // PrinterName("Epson Stylus 820 ESC/P 2", null)); // printServiceAttributeSet.add(new // PrinterName("hp LaserJet 1320 PCL 6", null)); // printServiceAttributeSet.add(new PrinterName("PDFCreator", null)); printServiceAttributeSet.add(new PrinterName(printerPath, null)); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); // exporter.setParameter(JRExporterParameter.INPUT_FILE_NAME, // "build/reports/PrintServiceReport.jrprint"); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter( JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet); exporter.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); exporter.setParameter( JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, DISPLAY_PAGE_DIALOG); exporter.setParameter( JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, DISPLAY_PRINT_DIALOG); exporter.exportReport(); System.err.println("Printing time : " + (System.currentTimeMillis() - start));

Actually I designed the Jasper report in A5 format but it's not printing right :(.

Category:java Time:2011-06-15 Views:4

Related post

  • How can I print directly to printer using jasper reports and grails? 2010-05-25

    Can someone please help me. I'm using grails and jasper grails plugin. I would like to send a jasper report directly to the printer from a click on my webpage. Can someone please point me to the right direction? --------------Solutions------------- T

  • How to print the jasper report on console 2011-08-19

    request.getSession().setAttribute("IMAGES_MAP", imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "" + request.getContextPath() + "//image?image=");

  • Printing jsf ArrayLIst via Jasper Report using JRBeanCollectionDataSource 2012-01-16

    I'm using a jsf array list to retrieve records based on some criteria. Now I want contents of this array list to be print via Jasper report. I followed following steps. Used empty datasource in Jasper report. Created Fields in jasper reports as those

  • Jasper report working fine in netbeans but gives exception when deployed as jar application 2010-11-20

    I'm working on my final year project using java swings and jasper reports for reporting.The application including the reports work fine when I run the application in netbeans but when I deploy it to a jar file and then try to execute it using my comm

  • Any way for Java Print to ignore lpoptions? 2011-12-19

    I'm using the javax.print API to print a Jasper Report on Debian Linux. For some reason the saved lpoptions (CUPS settings) always override settings choosen on the Java Print dialog. At this point the only way I am getting around this problem is to d

  • jasper-reports dynamic sub report generation 2011-11-24

    I'm trying to generate a report from java code with jasper-reports (without iReport). Have successfully created the following elements: Master report object (class: JasperDesign) named reportDesign Sub report object (class: JasperDesign) named subRep

  • Passing parameter to jasper report from java without DB 2011-10-25

    I am working on a simple standalone desktop application which would generate report based on the values passed to the program. There is no database usage. I have designed my jasper report with the ireport designer and added a parameter "ID_NO" and a

  • Jasper Reports: How can I print multiple pages in one page 2012-04-12

    I am new to Jasper Reports. I have a report with 2 groups. Depending on the query, multiple pages are being printed. 1st Group Height -- 95 Points and 2nd Group Height -- 144 Points I want these multiple pages to be printed in one page (I want to inc

  • Printing serial number in jasper report detail 2009-09-24

    I have created a jasper report. In that report in detail areaI have "serialNumber" column. That column wants to be auto incrementive and stats with "1". I am using hibernate for query. Sample code is : <detail> <band height="17" splitType="S

  • How to use jasper reports to print something only on the first page? 2010-05-21

    How to use jasper reports to print something only on the first page. I am using jasper reports for printing invoices and only on the 1st page I need to print the Remit Payment To section with the address following it. Customer address is also present

  • Jasper Reports + PDF generation issue 2010-07-10

    I have a jasper report that I'm displaying. Now I have an icon to get the same report in PDF. Now when I deploy the code in an OS with Tomcat it works fine, but the problem I'm facing now is that, we have created a VM Image of Ubuntu without UI. And

  • java code to display a floating point value in specified format in jasper report 2010-08-18

    The value 13.10 is printed as 13.1 in my jasper report , I want to print it as 13.10 itself , How to do it .The corresponding JRXML statement is <textFieldExpression class="java.lang.Float"><![CDATA[$F{temp_bill_tax}]]> </textFieldExpr

  • Jasper reports:Unknown column name issue 2010-10-20

    I am creating a jasper report using some database connection.i have added a new field to the report. That field does not exist in the database column. i have put that column in the report and assigning the value to this field using the expression. it

  • Jasper Reports: How to pass multiple SQL queries from a Java Program 2011-01-11

    I have constructed a Jasper Report using iReport tool, where in I have registered two data sets, one to polulate the data in a table, and other to display a chart. The configuration was successful using the tool and when i see the report it gives me

  • Jasper Report subreport issue 2011-02-26

    I have a master report which contains a lot of information and I need to add a Sub-Report. When I run JUnit Test of Master Report, an exception is thrown: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: The su

  • increase the width of a column dynamically in jasper reports in java 2009-08-01

    How do i increase the width of a column in jasper reports dynamically in java, i have tried changing many things in java side like reading the style sheet and changing the values. But in this case i don't know how to initialize the method which will

  • java.lang.OutOfMemoryError: Java heap space in jasper report 2009-10-19

    When i export content in doc format then i get java heap space error, java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at Source) at sun.nio.cs.StreamEncoder.writeBytes

  • how to set the report virtualizer parameter for jasper reports in java 2009-10-19

    How to set the REPORT_VIRTUALIZER parameter for jasper reports i java --------------Solutions------------- Here you can find a great article about jasper report virtualization. There are links to sample code in the comments.

  • Print label with repeating record using IReport (Jasper Report) 2010-08-01

    Use Case: Would like to use IReport to Label item sold in my shop. The thing with labels is that for each product there can be multiple items that need to be labeled. So let say product CarToy is 1 record in database (field name, description, price).

Copyright (C), All Rights Reserved.

processed in 0.480 (s). 13 q(s)