Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 5th, 2004, 01:11 PM
zerbitx zerbitx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 zerbitx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Printing a text file

I'm trying to print a page of formatted text, but I'm finding to java.awt.print to be extremely difficult to use. I tried that javax.print and it was great, but isn't implemented fully on the Mac yet, and I can't worry about the platform for this project. Is there a simple way to just create a text file, and have java.awt.print, print it? If not, I have a few questions about what I've got so far. I'm trying to print some highlighted fields like name. I want the Field title to be in bold, and the value to be just after it in a regular font, but I can't seem to get two different fonts on the same line with the correct horizontal placement. I just don't know how to find the end of the line. I'm placing the text in an invisible JTextArea, and pulling each line off at a time with


try {
lineStart = textarea.getLineStartOffset(lineNumber);
lineEnd = textarea.getLineEndOffset(lineNumber);
strText = textarea.getText(lineStart, lineEnd-lineStart);
}

The getLineEndOffset, seems to work here, but if I try graphics.drawString with a starting position of getLineEndOffset it's way off. I realize that drawString is part of graphics and getlineEndOffset is part of JTextComponent so I shouldn't expect the values to match up, but I don't have any other ideas.

-Ryan

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Printing a text file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway