Hi all,

I am trying to prepare PDF from HTML with japanese content, for which I am
using example code to do so.

Following is the code:

import java.io.*;
import java.io.IOException;

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;


public class GeneratePDF {

    public static void main(String[] args) {

              Document document = new Document(PageSize.A4, 80, 50, 30, 65);

        try {
                  PdfWriter.getInstance(document, new
FileOutputStream("jpn.pdf"));
String text1 = "";
FileInputStream fis = new FileInputStream("Chap1.html");
int len = fis.available();
byte b[] = new byte[len];
fis.read(b);
text1 = new String(b,"SJIS");
fis.close();

StringReader sr = new StringReader(text1);
            HtmlParser.parse(document, sr);

        }
        catch(Exception e) {
            e.printStackTrace();
            System.err.println(e.getMessage());
        }
    }
}

Contents of "Chap1.html":
<?xml version="1.0" encoding="SHIFT_JIS"?>
<html>
        <head>
<META http-equiv="Content-Type" content="text/html;
charset=shift_jis"></META>

        </head>
        <body leftmargin="36.0" rightmargin="36.0" topmargin="36.0"
bottommargin="36.0">

?????????????????????????????123 ashutosh salgarkar ???????
        </body>
</html>

jpn.pdf contents:
123 ashutosh salgarkar

Problem:
The output PDF contains only english characters and Japanese characters get
replaced by spaces.

Can anybody help me in this regard,

Thanks & Regards,
Ashutosh



}
}



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to