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