Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Set Space Ratio and Alignment     

                         

In this example , we are going to explain how we can set space ratio and how we can gives various alignment. You can make pdf with no space between the characters of a word .

Code Description:

setAlignment(int alignment):

We can set the aligment of a Paragraph with the method setAlignment(int alignment). The alignment can be one of the following values:

  1. Element.ALIGN_LEFT
  2. Element.ALIGN_CENTER
  3. Element.ALIGN_RIGHT
  4. Element.ALIGN_JUSTIFIED

setSpaceCharRatio:
If you want the alignment to be justified, the space between the words can be stretched, as well as the space between the characters of a word. The default ratio of this word-char space is 2.5. You can change this ratio with setSpaceCharRatio. For instance, if you don't want the space between the characters of a word .We can do this by:

writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);

The code of the program is given below:

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class SpaceWordRatio {  
    public static void main(String[] args)throws Exception {
      System.out.println("Example of Space Word Ratio");      
        Document document = new Document(PageSize.A4,
 
503505050);       
            PdfWriter writer = PdfWriter.getInstance(document, 
new 
FileOutputStream("spacewordratio.pdf"));
            document.open();
            String input = "Rose india is a java site which provide
 you online tutorial and online interview question help"
;
            Paragraph paragraph = new Paragraph(input);
            paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
            document.add(paragraph);
                document.newPage();
            writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
            document.add(paragraph);
            document.close();
    }
}

The output of the program is given below:

Download this example.

 

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
vector sorting
Display name
spring context
AOP Example Spring
set tooltip row jtable
sequential
calculating prime numb
jsp bean get property
JSF richfaces for tree
download tomcat
string number
jsp bean
download file struts 2
getting the day from t
<s:textarea>
reading excel file usi
Suggestion Box Using j
Arrays
PHP Date and Time Modi
read ascii
Java Tutorial
to find the max of thr
HOW TO UPLOAD IMAGE FR
EJB example program
Cloudscape Tutorials
jsp
dynamic insert value J
java math
Two Dimensional Array
java insert sort progr
how to edit a any file
BPEL Tutorials
Resource bundle
sé?«?é?«????é?«?é?«?é?
how to export zeroes t
Configure jstl in web.
java examples
date format
validat struts2 radio
how to hide a select t
superscript in java
jsp Insert data in mys
Why is it that excepti
Jude
reading file(java)
HTTP method GET is not
left align
design patterns
MULTIPLE SELECT COMBO
EL Implicit Objects
jasper report
programs using filters
if-else-then
struts pager tag
??â??â????â?????â?
combo box field call a
Photoshop Cloudy Backg
calculate mode in Java
ั?à¹???ะà¸?ะà¸?à
decimals
ejp
breakаÐ?????аÐ????а
fireTableCellUpdated
write to text file
array in javascript
clip source code
ASP.NET FileUploading
updating two parameter
how to clear data from
Tree Grid
types of heap sort
Hash Function in Java
bank application
jsp bank examples
Visual Basic Networkin
emailing file using js
generic
struts2 action element
tokenizer
s:iterate
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.