maestro Posted August 5, 2008 Share Posted August 5, 2008 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 More sharing options...
lucianc Posted August 6, 2008 Share Posted August 6, 2008 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 More sharing options...
maestro Posted August 6, 2008 Author Share Posted August 6, 2008 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: The problem occurs when the radius is “0”, if the value is different, then, the border is printed correctly. If I change the output (e.g. PDF or HTML) the result is correct too. JRE: build 1.6.0_05-b13Printers: Epson Stylus COLOR 740 ESC/P 2 HP LaserJet 1018 Regards Rafael Link to comment Share on other sites More sharing options...
lucianc Posted August 6, 2008 Share Posted August 6, 2008 The report printed fine for me. One more question: which JasperReports version are you using? Post Edited by Lucian Chiriţă at 08/06/08 17:02 Link to comment Share on other sites More sharing options...
maestro Posted August 6, 2008 Author Share Posted August 6, 2008 I test it on 2.0.4 and 3.0.0.Same error with both.Regards,Rafael Link to comment Share on other sites More sharing options...
lucianc Posted August 7, 2008 Share Posted August 7, 2008 This seems like a problem with your environment.Could you try the attached (Java) test and see whether the dashed rectangle prints fine?Regards,LucianPost Edited by Lucian Chiriţă at 08/07/08 10:18 Link to comment Share on other sites More sharing options...
lucianc Posted August 7, 2008 Share Posted August 7, 2008 I'm not able to attach the file. Trying again. Link to comment Share on other sites More sharing options...
lucianc Posted August 7, 2008 Share Posted August 7, 2008 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 More sharing options...
maestro Posted August 7, 2008 Author Share Posted August 7, 2008 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 More sharing options...
lucianc Posted August 8, 2008 Share Posted August 8, 2008 I'm not sure what to suggest. I searched the Sun JDK bugs database but nothing popped out.I haven't tested this on Windows yet. Maybe I'll be able to find some workaround when I'll do so.Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now