----- Original Message ----- 
From: "Bang Nguyen" <[EMAIL PROTECTED]>
To: "iText-question" <[email protected]>
Sent: Saturday, January 27, 2007 3:34 AM
Subject: Re: [iText-questions] Problem about using JSP to report PDF 
withJapanese font


Dear Bruno Lowagie,
I am very glad when it can show Japanese Text but now I have more problems:

1) When I include files in JSP file that have report PDF using iText.
ex: <%@ include file="tools.jsp"%>

OR
When I change the following code :

<%@
page import="java.io.*,
             com.lowagie.text.pdf.PdfWriter"
%><%
    // steps to output pdf file using iText
%>
to
<%@
 page import="java.io.*,
              com.lowagie.text.pdf.PdfWriter"
 %>
<%
     // steps to output pdf file using iText
 %>
 It always get errors:

org.apache.jasper.JasperException: getOutputStream() has already been called 
for this response


Now you know why you shouldn't use JSP to generate PDFs. The construct:

<%@
 page import="java.io.*,
              com.lowagie.text.pdf.PdfWriter"
 %>
<%
     // steps to output pdf file using iText
 %>

will introduce an extra CRLF in the response stream. It's very easy to 
introduce unwanted CRLF and spaces in JSP that don't matter in HTML but are 
deadly in PDF.


2) When I write directly Japanese text into JSP  file. It always show wrong 
font!
But In Java application, It is OK.
ex:
 document.add(new Paragraph("\u8ab0\u3082\u77e5\u3089\u306a\u3044",
     font));
-> It is OK.
 document.add(new Paragraph("Hello by Japanese 
(&#12371;&#12395;&#12385;&#12431;&#65281;). ",
     font));
-> It is not OK.

My project is using encoding: Shift_JIS (MS932)


JSP are compiled into servlets using some default encoding in the appication 
server. You'll have to set an explicit encoding in your application server 
if it's not MS932, that is, in every application server where the JSP is 
deployed. This problem doesn't occur in servlets because they are compiled 
in your development environment and will work everywhere.



Please help me how can I solve that problems.


Use servlets instead of JSP.

Paulo


Best regards,
Bang



"Bruno Lowagie (catch-all account)" <[EMAIL PROTECTED]> wrote: Bang Nguyen 
wrote:
> I have set CLASSPATH as your advice and now It works OK.  JSP can show
> Japanese text.
> Thank you very much.

I'm glad it works now.
I easily lose my patience with people
that forget to set the CLASSPATH.
It's in my nature...

> Now I have once more question:
>>(because as you know, we discourage the use of JSP
>>for binary files such as PDF files).
> Is that mean we sould not use JSP to report PDF...

When were taught how to write JSP files,
I hope you were told that JSP is to be
used to produce HTML or TXT files, and
that you shouldn't use JSP to produce
binary files such as JPG, PDF, GIF,...

This advice is given so that you can avoid
the many troubles that are inherent to JSP
and the *preservation of non-ASCII bytes*.
If you like stress or if you're a JSP guru,
you can ignore this advice. It's up to you ;-)

best regards,
Bruno



---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.


--------------------------------------------------------------------------------


> -------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
> 


-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to