Jump to content
Changes to the Jaspersoft community edition download ×

Unwanted margins on custom paper size Jasper Reports print jobs


alan_s_carneiro

Recommended Posts

I searched over and over again on the internet, but couldn't find nothing to help me.

 

We're having some problems with custom page size reports. It seems that the printing routine is always

adding a default margin to the print job, but in the JRXML we have defined a zero margin for the report.

This problem affects specially reports printed on label printers, as the report is suppose to be at the exact size

of the label, it actually, because of the inappropriate margin, leaves some labels unprinted before actually printing the

report or printing on report divided in two label.

Just for clarification, we use the class  to send the job to the printer. And generating the report in IReport, in preview, the

report is shown correctly, but the problem persists on print.

I'm sending together the report's JRXML for yours consideration

 

Thanks in advance for any help.

Link to comment
Share on other sites

  • 4 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Had the same issue. It looks like imageable are of thermal printer paper is not the same as paper size.

This worked for me:

// default jasper contextJasperReportsContext CTX = DefaultJasperReportsContext.getInstance();JasperPrint jp = ... // your filled jasper print objectPrintService ps = ... // your printerPrinterJob job = PrinterJob.getPrinterJob();job.setPrintService(ps);PageFormat fmt = job.getPageFormat(null);Paper p = fmt.getPaper();// set imageable area the size of whole printer paperp.setImageableArea(0, 0, p.getWidth(), p.getHeight());fmt.setPaper(p);switch (jp.getOrientationValue()) {    case LANDSCAPE:        fmt.setOrientation(PageFormat.LANDSCAPE);        break;    case PORTRAIT:        fmt.setOrientation(PageFormat.PORTRAIT);        break;}job.setPrintable(new JRPrinterAWT(CTX, jp), fmt);job.print();[/code]

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...