Documents

F

freesoft_2000

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.

If i am not wrong the printerjob class actually calls all page numbers and
the programmer does not have to implement that in his printable class. am i
right?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top