Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Font Face is not Worling With HTMLWorker ,Urgent solution requied.

sunil rajput

2005-08-12

Replies:

hi,

i have written simple code using the HTML , i want to change the Font Face to Times New Roaman, but when i run the below code it is not working , PDF is generated with the Arial Font. 

is there any solution for that and <p> tag is also not working.

do i need to include any other file for that???

it is urgent

Regds

Sunil Rajput


import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.html.HtmlParser;

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.html.simpleparser.*;

import java.util.*;
import java.io.*;

public class Test {

  public static void main(String[] args) {

  Test test = new Test();
  try {
    test.createUsingString();
    
  }catch (Exception e){
  }
 }

 public void createUsingString() {
  try {
    StringBuffer sBuff = new StringBuffer("<HTML>");
    sBuff.append("<head></head>");
    sBuff.append("<body>");
    sBuff.append("<table>");
    sBuff.append("<tr><td><font color=blue face='Times New Roaman'  >Coming Soon  <sup>hi<sup></font></td></tr>");
    sBuff.append("</table>");
    sBuff.append("</body>");
    sBuff.append("</html>");
    StringReader stringReader = new StringReader(sBuff.toString());
    Document document = new Document(PageSize.LEGAL,36,36,36,36);
    OutputStream output = new FileOutputStream("d:/itext/TestString1.pdf");

    PdfWriter writer = PdfWriter.getInstance(document, output);
    document.open();
    HTMLWorker worker = new HTMLWorker(document);
    worker.parse(stringReader);
    document.close();

  }catch (Exception ex){
   System.out.println( "Exception  " + ex.toString());
  }
 }
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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