Jump to content
We've recently updated our Privacy Statement, available here ×

How customize page 's size when print report


2005 IR Help

Recommended Posts

By: rungsiri - rung

How customize page 's size when print report

2004-02-08 00:44

I use JRPrintServiceExporter for print my report

code below:

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();

printRequestAttributeSet.add(MediaSizeName.ISO_A4);

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();

printServiceAttributeSet.add(new PrinterName("Epson LQ-300 ESC/P 2", null));

JRPrintServiceExporter exporter = new JRPrintServiceExporter();

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, Boolean.FALSE);

exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);

exporter.exportReport();

 

but I have problem about setting page ' s size. From above code that show in line "printRequestAttributeSet.add(MediaSizeName.ISO_A4);" PrintRequestAttributeSet allow to set fix page 's size such as A4, A3, envelop ,etc. But I want to set own size such as 8*8 inch which does not match in MediaSizeName. How can i do?? I try to set page 's size in xml(.jasper) and do not use PrintRequestAttributeSet. But when I execute printing, instead of I will get report with the size that I config in xml, I get report with A4 size.

 

 

 

 

 

 

By: Teodor Danciu - teodord

RE: How customize page 's size when print rep

2004-02-14 05:02

 

Hi,

 

First, if you are sure your document has to be 8x8 inch, then in the XML you should use 8 * 72 = 576 pixels.

 

In the XML use pageWidth="576" pageHeight="576"

and extract the margins to obtain the value for the

"columnWidth" attribute.

 

But when printing, this is a different story.

You have to instruct the printer about the size

of you paper and for that, check the Java Print

Service documentation for details about how to set

a custom paper size.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...