Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2008
    Location
    Syracuse, NY
    Posts
    6
    Rep Power
    0

    Default Table.print mystery...

    I am having a problem with the ‘JTable.print’ feature.

    I am using Java 1.6 on an iMac system with a HP SmartPrint 6510 printer.

    I found a similar problem on your site but the suggestions did not solve my problem. That thread was from 2011.

    The problem is that the format of the printout is fine but the characters are all a nonAscii character in lieu of the expected characters.

    By “the format of the printout is fine” i mean that there is a 5 character heading and there is a line for each item just as I expect. The mystery character is not in the Extended Ascii charts??? It looks like a vertical rectangle that outlines each character???

    The Table is visible in a dialog window that includes the print JButton.
    The selected print button navigates to my ‘doPrint’ method that contains the following code :

    Java Code:
    PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
    attr.clear();
    attr.add(	new Copies(1)	);
    attr.add(	OrientationRequested.PORTRAIT		);
    attr.add(	MediaSizeName.ISO_A4);	//	INVOICE );
    MessageFormat header =	new MessageFormat(	"FUDGE"	);	//	JShowReport.reportHeader	);
    MessageFormat footer = null;
    boolean showPrintDialog = false;
    boolean interactive = true;
    try		{
    	JShowReport.reportTable.print(
    		JTable.PrintMode.NORMAL,
    		header,
    		footer,
    		showPrintDialog,
    		attr,
    		interactive,
    		services[servicesIndex]);		}
    catch (		java.awt.print.PrinterException e		)		{
    	System.err.format("Cannot print %s%n", e.getMessage());
    }	//	End 'catch'...'
    The process creates an end user requested report constructed =F[Derby database table]…
    I have been looking into workarounds by by passing the JTable print approach and printing from an ArrayList<String> using the “Java Print Service” classes. But that also fails in that the HP printer software hangs up with a “Stopped: Unable to Convert PostScript file” error…

    Hopefully, I am overlooking something in the ‘JTable.print’ that you can help with…

    Regards,

    JimCrowell37

  2. #2
    gozzy is offline Member
    Join Date
    Jan 2017
    Posts
    46
    Rep Power
    0

    Default Re: Table.print mystery...

    It looks like a vertical rectangle that outlines each character???
    Any chance of a screenshot?

  3. #3
    Join Date
    Jun 2008
    Location
    Syracuse, NY
    Posts
    6
    Rep Power
    0

    Default Re: Table.print mystery...

    Table.print mystery...-badprintout-1.jpg

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Table.print mystery...

    That's simply the character that both printers and GUI displays fall back to when they are asked to display/print a character they don't understand, or the font they are using doesn't have a relevant glyph.

    So this is either a font issue, or a character set issue.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Join Date
    Jun 2008
    Location
    Syracuse, NY
    Posts
    6
    Rep Power
    0

    Default Re: Table.print mystery...

    Quote Originally Posted by Tolls View Post
    That's simply the character that both printers and GUI displays fall back to when they are asked to display/print a character they don't understand, or the font they are using doesn't have a relevant glyph.

    So this is either a font issue, or a character set issue.
    Thanks that kinda solved my problem.
    If I delete the code that sets the 'JTable' Font,
    Then I get a readable print out but not the required font family, style and size...

    With that success, I thought that my Java Class that contains the scripted Font was in error.
    Therefore i set the 'JTable' Font directly with a "Font font = new Font("Monospaced", Font.BOLD, 16) instance;

    But that also rendered the errant printout...

    So now my problem is that the only way I get a readable printout is to not set the 'JTable.Font' parameter?

    Any thoughts on this?

    Jim...

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Table.print mystery...

    What happens if you print to PDF.
    You should have a "printer" that does that...if Windows does (and it does), everything else should!
    :)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Join Date
    Jun 2008
    Location
    Syracuse, NY
    Posts
    6
    Rep Power
    0

    Default Re: Table.print mystery...

    Quote Originally Posted by Tolls View Post
    What happens if you print to PDF.
    You should have a "printer" that does that...if Windows does (and it does), everything else should!
    :)
    I do have a printer that does that but my objective is to make a printout in ‘Run-Time’ that my end users can obtain and use immediately.
    I am developing a Java stand alone application that includes a pretty basic "Report Writer" class that must work for any given printer.

    The "Report Writer" constructs an ArrayList<String> component with an element for each new line in the report. The only reason I am using a JTable is because I thought that the Java Print Service [JPS] would be easier to code and maintain. The printout I am receiving without the 'JTable.font' setting is passable but ideally I would like to control the printout's Font...

    The software currently uses a 'JTextPane' to display the report to my end user because the application has an optional style feature that uses the 'Java.text.Document' class to display certain "text phrases" with a given Look & Feel. That dialog has a 'Print' option. Next, I'll try to print the 'JTextPane' directly without the styling to see if I have the same 'font' problems. Ideally, I should print the report directly from the reports ArrayList<String> component. I'll spend some time on that as well.

    Anyway, thanks for the help. I will post my final code snippet here in case anyone else has this problem.
    Regards,
    Jim...

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Table.print mystery...

    Well, I was thinking more along the lines of using the print to PDF to see if that has the same issues, not as the solution.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 3
    Last Post: 04-09-2013, 04:11 PM
  2. Cant print the contents of a table
    By tudorH in forum JDBC
    Replies: 2
    Last Post: 03-20-2010, 06:53 PM
  3. Print the table in struts...
    By makpandian in forum Web Frameworks
    Replies: 1
    Last Post: 09-22-2009, 06:13 PM
  4. Print table
    By Implode in forum New To Java
    Replies: 7
    Last Post: 09-12-2009, 03:43 PM
  5. how to print out lines in a table- like form?
    By helloworld in forum New To Java
    Replies: 5
    Last Post: 02-10-2009, 09:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •