A better way to print text from within java ?

Hi, I want to make an app that brints out a bill (part of a bigger project for school) and I already know how to make my object printable and print it, but the "problem" lies in the graphics (or graphics2D) object that the print function uses to draw on the printable.
The bill contains large amounts of text and as far as I know graphics and graphics2D only have drawString() as method to draw a string, and on top of that it does not support the newline char, so is there a way to print large amounts of text in another way ?
also, since I'm using numbers and currency, would it be possible to alight text, so that it ends up like this:
name of item          100.00 Euros
name of other item       1.00 Euronicely aligned to the left for the names, and to the right for the numbers, the problem is that i'd like to keep that in a nonfixed width font, so calculating the needed position will be hard.
thanks in advance,
Boran.

Within the 2D Graphics system there are methods for dealing with this. Check out the AttrributedCharacterIterator class and the TextLayout class. A good read is
'Java 2D Graphics' by Jonathan Knudsen published by O'Reilly ISBN 1-56592-484-3 .

Similar Messages

  • Is there any way to print text messages from an iPhone 3gs?

    Is there any way to print text messages from an iPhone 3GS?

    The only ways to print any text messages from any of the iOS devices is to either do a print screen and then print those photos, or you could look for a program called TouchCopy that will allow you to download the SMS to the computer and you can handle them from there.

  • Is there a way to print texts/messages older than 90 days from phone without wireless printer?

    Is there a way to print texts/messages older than 90 days from phone without wireless printer?

    thanks for the reply....but forwarding to my email  - well, there were too many that I wanted printed.  But do appreciate your answering. 

  • Will not print text from PDFs - all other print is fine - Using nitro reader - Win7- HP4255

    Will not print text from PDFs - all other print is fine - Using nitro reader - Win7- HP4255

    Mulga
    Welcome to the HP Community Forum.
    Have you tried asking your question on the Nitro-Reader Forum?
    Nitro Reader Forum
    If you would like to try using the Adobe Reader, you might find help here:
    Manage Print Output with Print Preview
    See the section on PDF files
    Click the Kudos Thumbs-Up to show you appreciate the help.
    Click Accept as Solution when the Answer provides a Fix or Workaround!
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • How can I print texts from iPhone4 to Canon MX870

    How can I print texts from iPhone4 to Canon MX870

    The following gives instructions. http://support.apple.com/kb/HT4517
    Note that your carrier may not support it or may have added charges.
    To use this feature, enable Personal Hotspot on your cellular data plan. Contact your carrier for information and pricing.

  • How to print texts from iphone 4

    how to print text from iphone 4 without having to screenshot?

    An iOS cannot be downgraded or uninstalled...Apple has never supported doing this and removes the older iOS version files when a new iOS is released.

  • TS2755 is there a way to block texts from specific numbers to imessage with out turning imessage off?

    is there any way to block text from specific numbers to imessage without turning imessage off?

    Go to Settings > Messages > Send & Receive > You can be reached by iMessage at:
    Select the right facing arrow in a blue circle next to the email address this girl is sending iMessage to and select Remove This Email.
    If she has your cell phone number, she can switch to sending iMessage to that and there will be nothing you can do, but removing the email address will prevent you from receiving an iMessage addressed to that email address.

  • Is there any way to use Quickview from within Spotlight search results?

    I'm sure this has been answered previously, but my searches came up empty....
    Is there any way to use Quickview from within Spotlight search results? I'd like to be able to do a Spotlight search and hit the space bar for a quick Quickview look before actually launching the program. I'm guessing this isn't possible, but thought I'd ask...

    Thanks, Kappy.
    Duh...I meant Quick Look. Sorry about that.
    In any event, pressing the space bar in Spotlight just puts a space in the Spotlight search box - it doesn't open a Quick view of the highlighted item...

  • How to get the Weblogic Server Id from within java code

    I would like to log which server (among a cluster) a certain job is running on. Is there a way to get the server id from within Java code (this code is in a session bean if that is relevant.)
    By server id I mean the "Name" column in the summary of servers on the weblogic console.
    Thanks,
    ken

    Use the two entries close to the bottom of the page: "list WebLogic
    MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean.jsp"
    Nils
    Anatoly wrote:
    >
    Cameron,
    That page has these items on it:
    which one do you think helps with my issue?
    Misc WebLogic examples
    LongRunningTask
    Execute tasks in parallel using WebLogic Execute Threads
    Weblogic stats (5.1)
    Reload Servlet(s) programmatically (5.1)
    Network classload from WebLogic:using reflection,or the launcher
    Weblogic 5.1 debugging properties
    Seppuku pattern readme
    Using dynamic proxies to intercept EJB invocations (6.1)
    list WebLogic MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean
    Thanks to Marcelo Caldas for filter by type option and nice UI!
    Using com.sun.jdmk.comm.HtmlAdaptorServer with WebLogic 6.1
    Cool
    EJBGen
    Dimitri
    back
    "Cameron Purdy" <[email protected]> wrote in message news:<3c7a745d$[email protected]>...
    JMX ... see http://dima.dhs.org/misc/ for some info on JMX in Weblogic.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Anatoly" <[email protected]> wrote in message
    news:[email protected]..
    Does anyone know who to get the managing server URL's port
    from within the EJB code running on Weblogic 6.1?
    The URL port is not default (not 7001), but when creating
    initial context, I am not specifying the URL in properties.
    Due to that, trying to the the PROVIDER_URL property from
    environment does not return anything.
    Appreciate any responses.
    -Anatoly
    ============================
    [email protected]

  • Executing vbscript from within java

    Hi,
    Does anyone knows a way to execute a vbscript from within java and capture its output.
    thanks

    Do you mean emulate an interpreter?

  • Executing a perl script from within java application

    Hi,
    Does anyone knows a way to execute a perl script from within java.
    ---kirk

    Runtime.exec("perl myscript.pl");
    Of course whether that "works" depends on what the script does and where the java program runs.

  • Trying to use grep from within java,using exec command!

    Hi all!
    I would like to run a grep function on some status file, and get a particular line from it, and then pipe this line to another file.
    Then perfom a grep on the new file to check how many of the lines above are present in that file, and then write this value to a new file.
    The final file with a numerical value in it, i will read from within java,as one reads normal files!
    I can run simple commands using exec, but am kinda stuck with regards to the above!
    Maybe i should just do all the above from a script file and then run the script file from exec. However, i dont want to do that, because it kinda makes the system dependent,..what if i move to a new machine, and forget to install the script, then my program wont work!
    Any advise?
    Thanks
    Regards

    With a little creativity, you can actually do all that from the command line with a single command. It'll look a little crazy, but it can be done.
    Whether the script exists on the local machine or not has zero to do with platform indpendence. You assumedly have to get the application onto the local machine, so including the script is not really an issue at all. However, you're talking about system independence, yet still wishing to run command line arguments? The two are mutually exclusive.

  • Re-use message mapping from within java mapping?

    Hi there,                                                                               
    I have a question regarding java mapping. What I would like to do is to re-use an existing message mapping from within java mapping.
    Technicaly, message mapping is perfomed by com.sap.aii.mappingtool.tf3.AMappingProgram.execute, right? I would like to call that mapping program for a specifc message mapping from within my java mapping.
    Pseudo java code would look like this:
    public void execute(InputStream in, OutputStream out)
      throws StreamTransformationException {
    com.sap.aii.mappingtool.tf3.AMappingProgram.execute(in,out,'SomeMessageMapping');
    SomeMessageMapping is a message mapping that is defined in the integration repository.
    Is it possible? If so, could you provide me with some details?
    Thank you and best regards,
    Wolfgang

    Hi Wolfgang,
    very interesting idea?
    I would activa a dummy message mapping. than I would have a look in the file directory of the java-stack and try to find out the name of the *.class or *.jar file.
    On the other hand you could generate a tpz-transport-file an unpack this file, to explore the name of the *.class or *.jar
    Unfortunately I do not have access to the file system. So I can't explore the name.
    Regards Mario

  • Running ssh from within java program

    Hi!
    I am trying to start ssh from within java e.g.:
    Runtime run = Runtime.getRuntime();
    Process pro = run.exec("ssh -l xx 12.12.12.12");
    But it complains:
    socket: Operation not permitted
    ssh: connect to host 12.12.12.12 port 22: Operation not permitted
    Running ssh from the command prompt works just fine. It's run on win xp.
    What is the problem, and how can I avoid it?
    Endre

    Afraid not. I think maybe it's related to security permissions, but I am really not sure. If you can help, I would appreciate it.
    - Endre

  • Interactive PDF, Printing all text from within multi line scrolling field

    I have an A4 form created in Indesign CS4 and made interactive in acrobat 9 pro on Mac with several fields and have a question.
    I have a requirement for a number of the form fields to scroll in order to capture lengthy content if need be, my client also wants the ability to print the content in full from the fields if they so wish. However if the content is lengthy say filling more than the field area shows on screen how would this be printable?
    So :
    A form is set up to show 3 lines of text and employs a scrollable field solution to accommodate infinite text entry
    The user writes 6 lines of text (only 3 show on screen though due to the forced form field area)
    They want to print a record for hard copy or distribution showing all 6 lines
    I have just purchased the CS6 version with Acrobat X, but would like to solve this in with my previous version if possible, have only just installed CS6 and due to learning curve need to retain it in Acrobat 9 pro if possible.
    Thanks
    Matt HM

    Sure, you could do that fairly easily with just a bit JavaScript. It would have to be done by someone with Acrobat who receives the filled-in form. The text from the fields could be extracted and placed in a text file attachment that you create with JavaScript, and then extract the file attachment.
    For the general methods you'd use, see:
    createDataObject: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.450.html
    exportDataObject: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.463.html
    Another less flexible approach is to extract to a tab delimited text file: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.460.html
    For this, you can specify just the fields you want to include, so you don't have to bother with all of the fields in the form being included.

Maybe you are looking for

  • Oracle JRockit R28.2.2. OutOfMemoryError: classblock allocation

    Hi Folks, Well, we have a production Weblogic environment over Oracle JRockit Virtual Machine. The problem is that we are trying to avoid an " OutOfMemoryError" that is thrown everyday by a SOA Managed Server and causes a failure and stop of the mana

  • Put all pdf tags to the root directly

    Hello , I am trying to find a way to put all the sub tags into the tags root directly, for example: i have this tag tree 0>ROOT        1>  PART                = SEC                     = <P>        2> SEC               =SEC                     = <H1>

  • Report Template Layout Editing

    Hi all, I have few questions to check with you with regards to the report creation process. I read on the SAP help portal and it states the report creation process. Step 1 u2013 Create Report template (i.e. using CG42) Step 2 u2013 Edit the report la

  • Presentation Patterns in Flex

    Hello all I just came across a blog which sheds some light on presentation patterns. Here it is... http://blogs.adobe.com/paulw/ I was wondering whether some of these patterns or some others are very popular among flex developers. Thanks and Regards

  • Bank's Tech Team says Java can't do it

    I work for a major bank that just built a web based platform for writers like me to compose and submit our financial reports. We are told java won't allow us to paste graphs pictures OR Excel tables into our work !!!!! If java can paste pictures all