944,077 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1820
  • Java RSS
Dec 29th, 2004
0

Documents

Expand Post »
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

Java Syntax (Toggle Plain Text)
  1.  
  2. public void printData()
  3. {
  4. //This is the main printing function that prints out the document
  5.  
  6. try
  7. {
  8.  
  9. PrinterJob prnJob = PrinterJob.getPrinterJob();
  10.  
  11. PageFormat format = prnJob.pageDialog(prnJob.defaultPage());
  12. prnJob.setPrintable(new RTFRenderer(), format);
  13.  
  14. if (prnJob.printDialog() == false)
  15. {
  16. return;
  17. }
  18.  
  19. //The below command line prints out the document if the user clicked Ok
  20.  
  21. prnJob.print( );
  22. }
  23.  
  24. catch (PrinterException e)
  25. {
  26. e.printStackTrace();
  27. System.out.println("An error has occured");
  28. }
  29.  
  30. }

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
Similar Threads
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004
Jan 7th, 2005
0

Re: Documents

Hi everyone,

Is there no that can share their experiences with me

Yours Sincerely

Richard West
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004
Jan 9th, 2005
0

Re: Documents

You said none of the images were printing, how are you reading the file?

I don't know if this will have anything to do with it, but it might :cheesy:
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jan 10th, 2005
0

Re: Documents

Hi everyone,

I not reading any file in. I directly printing from the JTextPane by using rootviews thus it is something like a wysiwyg JTextPane

Richard West
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004
Jan 10th, 2005
0

Re: Documents

I don't know much about this, but Im curious. Responding to your first question, is there suppose to be a way you specify what a page actually is in code, or does the print dialog decide this itself?
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: message applet failed
Next Thread in Java Forum Timeline: altering a link





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC