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

Jagged 200DPI Print on Thermal Label Printer


aljungberg

Recommended Posts

I have a certain kind of report which is meant to be printed on a thermal label printer. I have created a report which is the right size, 4x6 inches, and added the single image which will be printed on the label.

 

The PDF files generated are good but when printing straight from Jasper the report becomes distorted and gets a jagged dotted appearance.

 

I have a hunch that Jasper is feeding the 200 DPI thermal printer a 300 DPI image (the original image file is 300 DPI), and that the thermal printer isn't doing a great job rescaling it to its own DPI.

 

Does anyone have any experience with this? Is Jasper aware of the DPI of the printer it prints on? If a source image is a higher DPI than the printer takes, what kind of scaling, if any, does Jasper apply?

 

If I print the PDF file generated using Acrobat Reader the result is perfect. So clearly there is some correct way to scale these images.

 

I realize that I can just scale and send the image to the printer directly in this special case, but we need to support label printers for more general reports as well and would like to use Jasper. Anyone know anything about this?

Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 months later...
We have confirmed that sending an image file with the correct DPI to Jasper works fine. If you send a 203DPI image, the printout comes through fine. But if you send a 300DPI image, Jasper seems to try to print in 300 DPI even that the printer is not capable of handling that resolution. Is there any way to convince Jasper to print with the appropriate resolution for the given printer?
Link to comment
Share on other sites

Hi,

 

I think a solution would be to use a javax.print.attribute.standard.PrinterResolution instance as a print request parameter added to the

PRINT_REQUEST_ATTRIBUTE_SET exporter parameter available for the JRPrintServiceExporter.

 

Check the supplied /demo/samples/printservice sample to see how we force the printing on a ISO_A4 sized paper.

You should be able to force the printer resolution in a similar way, using an instance of the PrinterResolution class added to the attribute set.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the advice. I went ahead and added a resolution attribute,

 

PrintRequestAttributeSet prattrs = new HashPrintRequestAttributeSet();

prattrs.add(new PrinterResolution(203, 203, ResolutionSyntax.DPI));

...

printer.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, prattrs);

 

This did not solve the jagged problem. What it did do was to disprove my theory that the printer itself is doing some kind of crazy scaling from 300 DPI to it native resolution and failing miserably. If I set the resolution to 75DPI I get a very small printout which none the less is just as jagged.

 

The printer has no reason to scale a 75DPI printout.

 

Then what's more likely is that Jasper is in fact scaling the image as it should. This is great news. But the printout is none the less jagged. Perhaps Jasper is doing some kind of bilinear scaling which results in a grayscale version of the image, which is then truncated to black and white by the printer?

Link to comment
Share on other sites

  • 2 weeks later...

Sorry, I can offer no help. But I'm very interested in printing to thermal printers with jasperreports.

What platform are you on, windows or unix? And what is the brand of your printer, and what driver do you use?

I could do some experiments on linux with either zebra or markpoint printers.

Maybe you could post the report you are tring to print?

Link to comment
Share on other sites

Sorry, I can offer no help. But I'm very interested in printing to thermal printers with jasperreports.

What platform are you on, windows or unix? And what is the brand of your printer, and what driver do you use?

I could do some experiments on linux with either zebra or markpoint printers.

Maybe you could post the report you are tring to print?

Link to comment
Share on other sites

Sorry, I can offer no help. But I'm very interested in printing to thermal printers with jasperreports.

What platform are you on, windows or unix? And what is the brand of your printer, and what driver do you use?

I could do some experiments on linux with either zebra or markpoint printers.

Maybe you could post the report you are tring to print?

Link to comment
Share on other sites

  • 4 months later...

The same problem occurs on an industrial Z4M plus printer. I am beginning to suspect that Jasper somehow generates a 300 DPI image and then tries to scale it down to the printer resolution. The scaling introduces the artifacts which is the printer's attempt at drawing grey scales created by bilinear filtering.

 

If there was some way to tell Jasper not to scale the image up to begin with this problem would not exist. The image is exactly the right resolution from the start. Or if Jasper could be told to use black and white scaling or generate a black and white document.

 

Anyone got any ideas?

Link to comment
Share on other sites

  • 6 years later...

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