Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-28-2004, 09:17 PM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question Documents

Hi everyone,

I have two weird questions but bear with me for a while.

The first question is about the printing of a styled document using the printable interface. i am using windows 98 and using the windows page format and print dialog. I have managed to print all the contents of the document using the windows print dialog but when i try to print a selected portion of the styled document(windows print dialog has an option of printing selected pages) always only the first page is printed.

This is what i did in my print method

Code:
public void printData()
{
//This is the main printing function that prints out the document

try
{

          PrinterJob prnJob = PrinterJob.getPrinterJob();

          PageFormat format = prnJob.pageDialog(prnJob.defaultPage());
          prnJob.setPrintable(new RTFRenderer(), format);

if (prnJob.printDialog() == false)
{
          return;
}

//The below command line prints out the document if the user clicked Ok

         prnJob.print( );
}

catch (PrinterException e)
{
       e.printStackTrace();
       System.out.println("An error has occured");
}

}
RTFRenderer is an external class where i implemented the printable interface

My next question is about the html document i have in a JTextPane and its printing functionality works on all java sdks(ie.1.1 - 1.4.2)
but when i compile my program under java sdk 1.5 update 1 only the text is printed but all the images are not printed but this is not the case on the other java sdks(ie.1.1 - 1.4.2). I find this rather weird.

I was thinking i was doing something wrong in both my questions so i downloaded a third party package called Document Renderer at www.fawcette.com but still had the same results.

I also went to manning website(www.manning.com) where they had a swing book with a chapter(Chapter22) on printing and i used the examples there to do the printing but i still got the same results.

Has anyone ever encountered this before. Could anyone point me to a tutorial or an open source package in which i can print the contents of the JTextPane if it contains either a styled document or HTML document.

I also went to sun's website and could not find out if both my problems is a bug or not and i hope someone can help me with this problem. Please note that no exceptions were thrown in both my problems.

Any help is greatly appreciated

Yours Sincerely

Richard West
freesoft_2000 is offline   Reply With Quote
Old 12-29-2004, 04:04 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,166
Belisarius is on a distinguished road
I believe some of the layout defaults in Java 1.5 have been changed. I have heard of other people having layout issues in Swing apps moving from 1.4 to 1.5. However, I don't do graphical applications in Java, so I'm afraid I'm at a bit of a loss to be more elaborate.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Documents freesoft_2000 Java 1 10-24-2004 10:22 AM


All times are GMT -8. The time now is 05:12 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting