hi all, i am new in JAVA...
What is the meaning of the following error??
pdf.java:57: unreported exception com.lowagie.text.DocumentException; must be ca ught or declared to be thrown
and my source code is under below!! /***************************************************/
import java.io.*; import javax.servlet.*;
import javax.servlet.http.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*; /**
**/
public class pdf extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try{
response.setContentType( "application/pdf" ); //PrintWriter out = response.getWriter();
// step 1: creation of a document-object
Document document = new Document();
// step 2: // we create a writer that listens to the document // and directs a PDF-stream to a temporary buffer ByteArrayOutputStream buffer = new ByteArrayOutputStream(); PdfWriter.getInstance( document, buffer );
// step 3: we open the document document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
//STEP 5: add image by Frankie;
Image gif = Image.getInstance("1.gif");
Image gif2 = Image.getInstance("2.gif");
document.add(gif);
document.add(gif2);
//STEP 6: add table by Frankie
Table Tablea = new Table(2,2); // 2 rows, 2 columns
Tablea.addCell("id");
Tablea.addCell("Name");
Tablea.addCell("1234567");
Tablea.addCell("Frankie");
document.add(Tablea); //STEP 7: add HTML list by Frankie
List list = new List(true, 20);
ListItem listItem;
list.setListSymbol("*");
list = new List(false, 20);
//list.setListSymbol(new Chunk("\u2022", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
listItem = new ListItem("TESTING HTML LIST ");
list.add(listItem);
document.add(list); String text=new String("TEST");
document.close();
// step 10: we output the writer as bytes to the response output DataOutput output = new DataOutputStream( response.getOutputStream() ); byte[] bytes = buffer.toByteArray(); response.setContentLength(bytes.length); for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); } }catch (IOException ignored) {} } }
_________________________________________________________________
Linguaphone : 學英語,免費學日語 http://go.msnserver.com/HK/30475.asp
------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions