JasperReports with a resolution other than 72dpi

I am trying to use JasperReports to print at a resolution above 72 dpi, with no success.

I need to use some resolution above 72 dpi, because I'm going to print on those pre-formatted adhesive labels that require some accuracy when adjusting positions. But since JasperReports can only use pixels, and AFAIK only supports 72dpi configuration, I cannot set fields, distances, etc. properly.

For example, if you need a 1 mm configuration, you need to convert to pixels, which will be 3px, as iReport will automatically convert (in fact, the real value is ~ 3.78px, but the pixel cannot be decimal, and iReport truncates instead of rounding it ) But, when you calculate it back by a millimeter (for example, when you print), it actually gets the size of ~ 0.79 mm, and not the old 1 mm that you need. If you consider a circular value (4px instead of 3px), you get the final print value of ~ 1.06 mm, still not the case.

Even if you think that 0.06 mm or 0.21 mm is not valuable, this is true when you have 20 or more sequential labels, and this error limit increases as you increase the number of labels.

Finally, is it possible to use JasperReports in any way to print reports with minimal accuracy, or is there any workaround for this problem?

+3
source share
3 answers

What worked as a kind of workaround was to use JRGraphics2DExporterParameter.ZOOM_RATIO as the PrinterExporter parameter with the correct scaling factor as a float.

For example, suppose I have a 144dpi (2 x 72dpi) configuration, the above ZOOM solution worked if I passed the value 0.5f as a parameter because it prints the equivalent size of 72dpi.

Given that this is a workaround, the actual DPI solution will be appreciated.

+1

Try

PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
attrs.add(new PrinterResolution(203, 203, ResolutionSyntax.DPI));

printerExporter.setParameter(
    JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, attrs);

( )

0

In my answer to this question in the Jasperrport forum, you can answer the question:

You can create a large report image with good resolution and scale the image to a small one.

http://community.jaspersoft.com/questions/517024/export-report-image-jpg-bmp-or-any-format

0
source

Source: https://habr.com/ru/post/1724691/


All Articles