Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Full Justification of Strings

  1. #1
    agillator is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Full Justification of Strings

    My problem is to produce a fully justified PDF paragraph through PDFBox. I have found that I must provide a series of justified strings, i.e. the justification is done before converting to PDF. I know I can use the brute force method of adding pixels until a string is the apropriate length, but that certainly seems the hard way. What am I missing or overlooking? Is there an easier way in Java? The must be something better than "if at first you don't succeed get a bigger hammer". Adding spaces between words is not the answer, but all I can find is left, right and center justification, not full justification. Suggestions? Solutions?

    Thanks in advance.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default Re: Full Justification of Strings

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Full Justification of Strings

    Are you committed to using PDFBox? I haven't used iText much, but I see it has a constant for ALIGN_JUSTIFIED in the com.itextpdf.text.Element interface which is implemented by com.itextpdf.text.Paragraph

    db
    gimbal2 likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,104
    Rep Power
    6

    Default Re: Full Justification of Strings

    Indeed. When I was doing things and stuff with PDFs, I used PDFBox to 'read' PDFs (as in - turn them into plain text so I could feed them into a Lucene indexer) and I used iText to create PDFs. No API beats iText when it comes to PDF generations, IMO.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    agillator is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: Full Justification of Strings

    Thanks for the replies. I hadn't found anything on Google, but then I hadn't been smart enough to consider the multicolumn approach, I kept searching for some variation of justification.

    As for iText, originally I had considered it but didn't like their user agreement when I scanned it. It sounded too much like 'You are free to use as long as you aren't doing anything, but for any real use you must buy a license'. Apache's with PDFBox is a bit looser. Of couse that may have been a product of trying to do something at 3 a.m. The closed eyelids keep getting in the way. Trying to use PDFBox has been a challenge. I will take another look at iText since you make it sound as if it will do what I need.

    Many. many thanks for your assistance. And for each of you, what is that Irish blessing? Something about "May the sun always shine on you, your path always be downhill, the wind always be at your back and may you be in Heaven an hour before the Devil knows you're gone."

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,104
    Rep Power
    6

    Default Re: Full Justification of Strings

    That sounds like a quote from Boondock Saints :)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Getting first initial and last name from full name
    By Gagnrath in forum New To Java
    Replies: 3
    Last Post: 08-01-2013, 09:20 PM
  2. How can I see full program
    By keki in forum New To Java
    Replies: 8
    Last Post: 05-14-2012, 11:18 PM
  3. Full screen
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •