Jump to content
Changes to the Jaspersoft community edition download ×

maestro

Recommended Posts

Hello,

I'm trying to print a report using the jasper viewer where the content has a dotted / dashed rectangle. On the screen, it appears correctly, but when it's printed the rectangle's border line is solid.

This problem doesn't happen when ellipses or lines are printed with dashed border.

It sounds like a bug.

How can I print a dashed rectangle?

Thnx advance!

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

I just tried printing dashed/dotted rectangles and it worked fine.

Do you have a full sample to illustrate this?  Also, this might be a problem with the specific JRE or printer you are using, so please include information about your environment as well.

Regards,

Lucian

Link to comment
Share on other sites

Hello Lucian,

 

Thank you for the reply.

I've created the template via iReport (find attached the jrxml and jasper files).

I just execute the template to run on JRViewer Preview and and then I print it, but the rectangle's border is solid on the paper.

 

Notes:

  1. The problem occurs when the radius is “0”, if the value is different, then, the border is printed correctly.

  2. If I change the output (e.g. PDF or HTML) the result is correct too.

 

JRE: build 1.6.0_05-b13

Printers: Epson Stylus COLOR 740 ESC/P 2

          HP LaserJet 1018

 

Regards

 

Rafael

 

Link to comment
Share on other sites

Still not able, so I'm listing here PrintTest.java:

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.MediaPrintableArea;


public class PrintTest {

    public static void main(String[] args) throws Exception {
        Printable rectangle = new Printable() {
            public int print(Graphics graphics, PageFormat pageFormat,
                    int pageIndex) throws PrinterException {
                if (pageIndex > 0) {
                    return NO_SUCH_PAGE;
                }
               
                BasicStroke stroke = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER,
                        10f, new float[]{4f, 4f}, 0f);
               
                Graphics2D grx = (Graphics2D) graphics;
                grx.setColor(Color.BLACK);
                grx.setStroke(stroke);
                grx.drawRect(41, 32, 509, 75);
               
                return PAGE_EXISTS;
            }
        };
       
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintable(rectangle);
       
        PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
        attrs.add(new MediaPrintableArea(0f, 0f, 210f, 297f, MediaPrintableArea.MM)); //A4 paper
       
        if (job.printDialog(attrs)) {
            job.print(attrs);
        }
    }

}
 

Link to comment
Share on other sites

Hello Lucian,

Thank you very much for your attention.
I tested your class on my environment (Windows XP Pro SP2) and it did not work, still solid.

So, I decided to print (compiling with Java 5 and 6) in another OS: Mac OS X 10.5.4, Ubuntu 8.0.4, Windows 2003 R2, Windows 2000 and Windows Vista Business.
The Mac OS and Ubuntu print it correctly, but all the Windows family cannot print the rectangle dashed.

What can you suggest?

Thanks again,

Rafael

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