Quoting "Ing. Omar Rojas Gast�lum" <[EMAIL PROTECTED]>:
> ***************************************
> org.apache.jasper.JasperException: The document has no pages.
> at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
You are closing a document that has no content.
Why doesn't it have any content?
Because you probably have an error retrieving
the PNG and an exception is thrown.
You should have the ioe.getMessage()
somewhere in your logfile before the Exception
you posted.
By the way, this is not going to work:
Do you see all the newlines?
I added some \n so that you don't miss them.
All those newlines are added to your binary
screwing it up and making it unreadible
(see the FAQ).
> <%@ page import="java.awt.Color"%>\n
> <%@ page import="java.io.FileOutputStream"%>\n
> <%@ page import="java.io.IOException"%>\n
> <%@ page import="com.lowagie.text.*"%>\n
> <%@ page import="com.lowagie.text.pdf.PdfWriter"%>
> <%@ page import="com.lowagie.text.pdf.BaseFont"%>
> <%@ page import="com.lowagie.text.pdf.PdfContentByte"%>
> <%
> // out.println("PDF GENERATION IN PROGRESS...");
>
> // step 1: creation of a document-object
> Document document = new Document();
>
> String apellidos = null;
> String nombres = null;
> String fecha = null;
>
>
>
>
> try {
>
>
> //Read http request parametters
>
> apellidos = "RG";
>
> nombres = "Omar";
>
> fecha = "02/02/2003";
>
> // step 2:
> // we create a writer that listens to the document
> // and directs a PDF-stream to a file
>
> PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream("D:/ProyectoCATWEBPruebas/catweb/PDFGenerated/test.pdf"));
>
> // step 3: we open the document
> document.open();
>
> PdfContentByte cb = writer.getDirectContent();
document.add(new Paragraph("Please try to walk before you run."));
>
> // step 4: we add content
> Image jpg1 = Image.getInstance("c:/temp/visa.png");
What comes here is probably not executed.
> jpg1.scalePercent(24);
> jpg1.setAbsolutePosition(0,0);
>
> document.add(jpg1);
> BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
>
> cb.setFontAndSize(bf, 12);
> cb.beginText();
>
> cb.setTextMatrix(((int)(220*0.24)),(int)(11*72)-((int)(365*0.24)));
> cb.showText(apellidos);
>
>
> cb.setTextMatrix(((int)(220*0.24)),(int)(11*72)-((int)((365+115)*0.24)));
> cb.showText(nombres);
>
>
> cb.setTextMatrix(((int)(220*0.24)),(int)(11*72)-((int)((365+115*4)*0.24)));
> cb.showText(fecha);
>
> cb.endText();
>
> }
> catch(DocumentException de) {
> out.println(de.getMessage());
> }
> catch(IOException ioe) {
> out.println(ioe.getMessage());
> }
You get thrown here, you have nothing added to the document
so it throws an exception.
> // step 5: we close the document
> document.close();
> out.println("<SCRIPT language=/"JavaScript/">");
> out.println("<!--");
> out.println("window.location.href = '/test.pdf'; ");
> out.println(" //-->");
> out.println("</SCRIPT>");
> %>
-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions