Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
RtfTOC how to set fonts and indentation

RtfTOC how to set fonts and indentation

2006-07-25       - By dgray@(protected)

 Back
Reply:     1     2  

I have also found that settings made through RtfParagraphStyle are not
reflected in
the actual TOC of the final document in Word. The example below demonstrates
the
problem. I define 2 TOC RtfParagraphStyles: MYTOC1 and MYTOC2. When I open the
generated doc in Word these 2 styles are listed as registered paragraph styles
but are
not used in the generated TOC.

__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___

package com.dave;

import java.awt.Color Source code of java.awt.Color;
import java.io.FileOutputStream Source code of java.io.FileOutputStream;

import com.lowagie.text.Chunk Source code of com.lowagie.text.Chunk;
import com.lowagie.text.Document Source code of com.lowagie.text.Document;
import com.lowagie.text.Font Source code of com.lowagie.text.Font;
import com.lowagie.text.PageSize Source code of com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph Source code of com.lowagie.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2 Source code of com.lowagie.text.rtf.RtfWriter2;
import com.lowagie.text.rtf.field.RtfTOCEntry Source code of com.lowagie.text.rtf.field.RtfTOCEntry;
import com.lowagie.text.rtf.field.RtfTableOfContents Source code of com.lowagie.text.rtf.field.RtfTableOfContents;
import com.lowagie.text.rtf.style.RtfFont Source code of com.lowagie.text.rtf.style.RtfFont;
import com.lowagie.text.rtf.style.RtfParagraphStyle;

public class TOCTest {

  /**
  * @(protected) args
  */
  public static void main(String[] args) {
    try {
      Document document = new Document(PageSize.LETTER, 50, 50, 50,
50);
      RtfWriter2 rtfWriter = RtfWriter2.getInstance(document,
          new FileOutputStream("TOCTest.rtf"));
      RtfFont header1Font = new RtfFont("Arial", 16, Font.BOLD,
Color.BLACK);
      RtfFont header2Font = new RtfFont("Arial", 14, Font.BOLD,
Color.BLACK);
      RtfFont mainFont = new RtfFont("Arial", 12, Font.NORMAL,
Color.BLACK);
      RtfParagraphStyle myToc1 = new RtfParagraphStyle
("MYTOC1", "Arial", 14, Font.BOLD, Color.RED);
      RtfParagraphStyle myToc2 = new RtfParagraphStyle
("MYTOC2", "Arial", 12, Font.NORMAL, Color.GREEN);
      myToc2.setIndentLeft(20);
       rtfWriter.getDocumentSettings().registerParagraphStyle(myToc1);
       rtfWriter.getDocumentSettings().registerParagraphStyle(myToc2);

       document.open();
       document.add(new Paragraph("Table of Contents", header1Font));
       document.add(Chunk.NEWLINE);
       Paragraph para = new Paragraph();
       para.add(new RtfTableOfContents("RIGHT CLICK HERE AND SELECT
\"UPDATE FIELD\" TO UPDATE.", header2Font));
       document.add(para);
       
       document.add(Chunk.NEXTPAGE);
       String title = "Header One";
       document.add(new RtfTOCEntry(title, myToc1));
       document.add(new Paragraph(title, header1Font));
       document.add(Chunk.NEWLINE);
       title = "Section 1.1";
       document.add(new RtfTOCEntry(title, myToc2));
       document.add(new Paragraph(title, header2Font));
       document.add(Chunk.NEWLINE);
       String body = "Text for section 1.1.";
       document.add(new Paragraph(body, mainFont));
       document.add(Chunk.NEWLINE);
       title = "Section 1.2";
       document.add(new RtfTOCEntry(title, myToc2));
       document.add(new Paragraph(title, header2Font));
       document.add(Chunk.NEWLINE);
       body = "Text for section 1.2.";
       document.add(new Paragraph(body, mainFont));
       document.add(Chunk.NEWLINE);
       document.add(Chunk.NEXTPAGE);
       title = "Header Two";
       document.add(new RtfTOCEntry(title, myToc1));
       document.add(new Paragraph(title, header1Font));
       document.add(Chunk.NEWLINE);
       title = "Section 2.1";
       document.add(new RtfTOCEntry(title, myToc2));
       document.add(new Paragraph(title, header2Font));
       document.add(Chunk.NEWLINE);
       body = "Text for section 2.1.";
       document.add(new Paragraph(body, mainFont));
       document.add(Chunk.NEWLINE);
       title = "Section 2.2";
       document.add(new RtfTOCEntry(title, myToc2));
       document.add(new Paragraph(title, header2Font));
       document.add(Chunk.NEWLINE);
       body = "Text for section 2.2.";
       document.add(new Paragraph(body, mainFont));
       document.add(Chunk.NEWLINE);
      document.close();
    } catch(Exception e){
      System.out.println("Exception: " + e.getMessage());
    }
  }

}


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

©2008 junlu.com - Jax Systems, LLC, U.S.A.