yes, sorry, you're right itext-1.4.3 Adobe Acrobat Reader 7.0
i am ataching the PDF and the source code of Servlet Thank you very much On Wed, 13 Sep 2006 14:00:24 -0700 "Mark Storer" <[EMAIL PROTECTED]> wrote:
You've got to give us more to go on than that... What's giving the error message? What version of iText are you using? And a copy of the problem PDF is always helpful.--Mark Storer Senior Software Engineer Cardiff.com#include <disclaimer> typedef std::Disclaimer<Cardiff> DisCard;-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Wednesday, September 13, 2006 12:17 PM To: [email protected] Subject: [iText-questions] Unrecognized TokenI installed in 3 different machines an application that insert Text to PDF using PDF Templates and DirectContent like as an Example in the tutorial.It's a Web Application that merge pdf and text on Server and display it from a Servlet.But in a HP-UX, with WebSphere 5.1, i receive an error Unrecognized Token: 'E6' Illegal Operation: 'BT' Anybody help me? Regards Gustavo -------------------------------------------------------------- -----------Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security?Get stuff done quickly with pre-integrated technology to make your job easierDownload IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
control.pdf
Description: Adobe PDF document
package gestor;
import javax.servlet.http.HttpServlet;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
import configuracion.ItemsBean;
import configuracion.PlantillasBean;
import configuracion.ValidacionesBean;
import dto.Item;
import dto.Plantilla;
/**
* Servlet Class
*
* @web.servlet name="visorPdf"
* display-name="Name for visorPdf"
* description="Description for visorPdf"
* @web.servlet-mapping url-pattern="/visorPdf"
* @web.servlet-init-param name="A parameter"
* value="A value"
*/
public class visorPdf extends HttpServlet {
public visorPdf() {
// TODO Auto-generated constructor stub
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException {
resp.setHeader("Expires", "0");
resp.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
resp.setHeader("Pragma", "public");
resp.setContentType("application/pdf; charset=utf-8");
/*String plantilla=req.getParameter("plantilla");
if (plantilla==null || plantilla.equals("")) throw new
ServletException("Plantilla no seteada");
PlantillasBean pb=new PlantillasBean();
Plantilla p=pb.findPlantilla(plantilla);
ItemsBean ib=new ItemsBean();
ib.setPlantilla(p.nombre);
String[] activos=req.getParameterValues("activo");
Set _items=ib.getItemsActivos(activos);*/
//reemplazo
String[] activos=req.getParameterValues("activo");
Plantilla p=(Plantilla)req.getAttribute("plantilla");
Set _items=(Set)req.getAttribute("items");
Object[] items=_items.toArray();
Arrays.sort(items,new Comparator(){
public int compare(Object arg0, Object arg1) {
return
((Item)arg0).getPag()-((Item)arg1).getPag();
}
});
PdfReader reader = new
PdfReader(configuracion.DefGenerales.rutaConf + p.getRuta());
int n = reader.getNumberOfPages();
Rectangle psize = reader.getPageSize(1);
float width = psize.width();
float height = psize.height();
try {
ServletOutputStream out=resp.getOutputStream();
Document document = new Document(new Rectangle(width, height));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document,baos);
document.open();
PdfContentByte cb = writer.getDirectContent();
int item=0;
int itemsLength=items.length;
for(int i=1;i<=n;i++){
document.newPage();
//agrega info de plantilla
if (activos==null || activos[0].equals("_PLANTILLA")){
PdfImportedPage page1 =
writer.getImportedPage(reader, i);
cb.addTemplate(page1,0,0);
}
//item valido
while (item<itemsLength && ((Item)items[item]).getPag()==i){
Item it=(Item)items[item];
// si existe valor lo coloca, sino lo crea (para
previsualizacion)
String valor=it.getValor();
if (valor==null){
valor=ValidacionesBean.generarEjemplo(it);
}
BaseFont bf=it.getBF();
cb.beginText();
cb.setFontAndSize(bf, it.getTamano());
cb.showTextAligned(it.getAlign(), valor, it.getX(),
height-it.getY(), 0);
cb.endText();
item++;
}
}
document.close();
resp.setContentLength(baos.size());
reader.close();
baos.writeTo(out);
out.flush();
} catch (Exception e){
throw new ServletException(e);
}
}
}
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
