I tried the iText XML by handcoding it. It seems it is not generating the PDF to use any other font except the default one. I used the following input xml and program.
[code] test.java ------------ import java.io.FileOutputStream; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import com.lowagie.text.*; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.xml.*;
public class test
{
public static void main( String[] args )
{
Document document = new Document();
try
{
PdfWriter.getInstance( document, new FileOutputStream( "test.pdf" ) );
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse( "test.xml", new SAXiTextHandler( document ) );
}
catch ( Exception e )
{
System.out.println( e.getMessage() );
}
}
}
test.xml
-----------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE ITEXT SYSTEM "http://itext.sourceforge.net/itext.dtd">
<itext creationdate="Fri Jan 23 12:22:29 MST 2004" producer="iTextXML by lowagie.com">
<paragraph leading="12.0" size="10.0" align="Default">
<chunk size="10.0">Testing default font</chunk>
</paragraph>
<paragraph leading="12.0" font-family="Courier" size="10.0" align="Default">
<chunk font-family="Courier" size="10.0">Testing Courier font</chunk>
</paragraph>
<paragraph leading="12.0" font-family="Lucida Console" size="10.0" align="Default">
<chunk font-family="Lucida Console" size="10.0">Testing Lucida Console font</chunk>
</paragraph>
<paragraph leading="12.0" font-family="Verdana" size="10.0" align="Default">
<chunk font-family="Verdana" size="10.0">Testing Verdana font</chunk>
</paragraph>
<paragraph leading="12.0" font-family="TSC_Avarangal" size="10.0" align="Default">
<chunk font-family="TSC_Avarangal" size="10.0">Testing TSC_Avarangal font: §ƒ¡ýŠ ¦†ýÈ¢
</chunk>
</paragraph>
</itext>
[/code]
Christian,
I tried your package as well. Initially I tried your /test/print/font-test.xml and it worked fine. But when I used the following xml file, the generated PDF did not show the text using the font mentioned. It failed for Lucida Console, Verdana and TSC_Aravarangal.
[code]
t1.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<document size="A4" margin-left="25" margin-right="25" margin-top="25" margin-bottom="25">
<paragraph>
Default font.
</paragraph>
<paragraph>
<font family="Courier" style="normal" size="14">
Testing Courier font
</font>
</paragraph>
<paragraph>
<font family="Lucida Console" style="normal" size="14">
Testing Lucida Console font
</font>
</paragraph>
<paragraph>
<font family="Verdana" style="normal" size="14">
Testing Verdana font
</font>
</paragraph>
<paragraph>
<font family="TSC_Avarangal" style="normal" size="14">
Testing TSC_Avarangal font - §ƒ¡ýŠ ¦†ýÈ¢
</font>
</paragraph>
</document>
[/code]
This leads to me believe that there is somewhere some problem with either embedding the font in the PDF or linking the font with text in the PDF.
The following code works without a problem.
[code] import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.*; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.xml.*;
public class test2
{
public static void main( String[] args )
{
Document document = new Document();
try
{
PdfWriter.getInstance( document, new FileOutputStream( "test2.pdf" ) );
document.open();
BaseFont baseFont = BaseFont.createFont( "c:\\winnt\\fonts\\tscava.ttf", BaseFont.WINANSI, BaseFont.NOT_EMBEDDED );
Font font = new Font( baseFont, 8 );
String text1 = "Testing the default font.";
String text2 = "Testing TSC_Avarangal: §ƒ¡ýŠ ¦†ýÈ¢";
document.add( new Paragraph( text1 ) );
document.add( new Paragraph( text2, font ) );
}
catch ( DocumentException de )
{
System.err.println( de.getMessage() );
}
catch ( IOException ioe )
{
System.err.println( ioe.getMessage() );
}
document.close();
}
}
[/code]
If you have time to look into this issue, please do so and let me know your feedback regarding this.
Thanks, Jones.
_________________________________________________________________
Let the new MSN Premium Internet Software make the most of your high-speed experience. http://join.msn.com/?pgmarket=en-us&page=byoa/prem&ST=1
------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions