Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:43:56+00:00 2026-06-09T18:43:56+00:00

I am using Java & Itext2.1.7 for generating pdf and I have written the

  • 0

I am using Java & Itext2.1.7 for generating pdf and I have written the following HTML. But it is not breaking words when they are too long.

String td ="<td colspan=\"2\" align=\"left\" style=\"table-layout: fixed;word-wrap:break-word;white-space: normal;\"><b>"
                    + verylongwordverylongwordverylongword + ":</b></td>"

Can someone help me achieving this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:43:57+00:00Added an answer on June 9, 2026 at 6:43 pm

    Itext 2.7.1 does not support word-wrap : break-word property. Following is the link for that.

    http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html

    So I have manually break the words according to the no of columns of the Table and by taking assumption of maximum letters around 60-65.Following is the code for that.

    public String getBrokenWordsForPdfGeneration(String longString, int cutIndex){
           StringBuffer mainStringBuffer = new StringBuffer(longString);
           String returnString = "";
           while(mainStringBuffer != null && mainString.length()>0 &&                              
    mainString.subString(0,mainString.length()>cutIndex?cutIndex:mainString.length()) != null){ 
              if(mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim().contains(" ")){
                   returnString += mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim();
                   mainStringBuffer.delete(0,mainString.length()>cutIndex:mainString.length());
              }else{
                  returnString += mainStrig.subString(0,mainString.length()>cutIndex:mainString.length()).trim()+ " ";
                  mainStringBuffer.delete(0,mainString.length()>cutIndex:mainString.length());
              }
        }
        return returnString;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked to develop an interactive website using java & mysql: using
Using Java regex pattern I want to match the & symbol. But it should
Currently we have developed application using Java 6 based on windows 32bit(Dual core &
Im using Oracle, BlazeDS, Java & Flex. I have an ArrayCollection containing data from
I'm using GWT 2.4 with Java & Mozilla FF 7. I have a TextBox
I have a web application developed using Java (Java EE), spring & Hibernate. We
I am using blackberry java plugin for eclipse for development & as i downloaded
I am using the latest Eclipse for Java EE & the latest JBoss Tools
My understanding is that when using && as an mathematical operation in Java, if
I've been recently trying to connect to a hosted MySQL using Java but can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.