Hi,
I had doubt regarding PDF generation and i am novice in iText(using it the first time). i am finding problems in displaying Japanese, Chinese and Korean characters.
The File is getting generated but i am not able to view these characters.Other 1character/byte (i.e. normal english characters) types are easily viewable.
My problem is how do i make these characters viewable if i have to parse the data.
I am parsing the Chinese, Japanese charcter data as given below:
Document document = new Document(PageSize.A4, 80, 50, 30, 65);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ServletOutputStream objServletOutputStream = response.getOutputStream();
response.setContentType("application/pdf;charset=utf-8");
PdfWriter writer = PdfWriter.getInstance(document,baos);
writer.setEncryption(PdfWriter.STRENGTH40BITS,null,null,~(PdfWriter.AllowPrinting|PdfWriter.AllowPrinting|PdfWriter.AllowModifyContents|PdfWriter.AllowCopy|PdfWriter.AllowModifyAnnotations|PdfWriter.AllowFillIn|PdfWriter.AllowScreenReaders|PdfWriter.AllowAssembly|PdfWriter.AllowDegradedPrinting));
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
ByteArrayInputStream in1 = new ByteArrayInputStream(parseHTMLString.getBytes("UTF-8"));
parser.parse(in1,new SAXmyHtmlHandler(document));
response.setContentLength(baos.size());
baos.writeTo(objServletOutputStream);
objServletOutputStream.flush();
When i went through the documentation i found that we have to use CJK fonts, but i am not sure how can we use it when i am parsing data, because what i understand from the examples posted at the iText site is that the string should be added as a paragraph object, and then this should be added to the document object. But my HTML string itself has <P> and <font> tags which are parsed my SAXmyHtmlHandler internally.Also the contents should be set to ArialUnicodeMS Font.
Correct if i am wrong and also please guide me with PDF generation. Also it will be helpfull if any other alternative methods are suggested.
Please help.....
Thanks & Regards,
Ashwin
DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to Tata Consultancy Services Limited. It must not be printed, read, copied, disclosed, forwarded, distributed or used (in whatsoever manner) by any person other than the addressee. Unauthorized use, disclosure or copying is strictly prohibited and may constitute unlawful act and can possibly attract legal action, civil and/or criminal. The contents of this message need not necessarily reflect or endorse the views of Tata Consultancy Services limited on any subject matter. Any action taken or omitted to be taken based on this message is entirely at your risk and neither the originator of this message nor Tata Consultancy Services Limited takes any responsibility or liability towards the same. Opinions, conclusions and any other information contained in this message that do not relate to the official business of Tata Consultancy Services limited shall be understood as neither given nor endorsed by Tata Consultancy Services Limited or any affiliate of Tata Consultancy Services Limited. If you have received this message in error, you should destroy this message and may please notify the sender by e-mail. Thank you. |