Java iText正在运行的Google应用程序引擎
我正在尝试使用google app engine在java中创建pdf,但它还不起作用:Java iText正在运行的Google应用程序引擎,java,google-app-engine,itext,Java,Google App Engine,Itext,我正在尝试使用google app engine在java中创建pdf,但它还不起作用: @SuppressWarnings("serial") public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setCont
@SuppressWarnings("serial")
public class GuestbookServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/pdf");
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("HelloWorld.pdf"));
document.open();
document.add(new Paragraph("Hello World"));
document.close();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这就是错误:
HTTP ERROR 500
Problem accessing /guestbook. Reason:
com/itextpdf/text/DocumentException
Caused by:
java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException
我已经阅读了java.awt和java.nio与google appengine的不兼容性。但我不知道怎么做。谷歌应用程序引擎是否有itext的特殊版本?或者你知道有什么线索可以帮助我吗?是的,有一个GAE版本的iText。请参阅以观看演示。GAE端口由iText软件分发。没有在线获取的链接。这意味着只有在itextpdf.com.Hello上填写销售表格,才能根据要求获取该信息!我填写了销售表格,他们说我可以在这里测试下载:一个普通版本,因为如果没有证明iText有正确的GAE解决方案,我就不能购买许可证。我能用它吗?你要GAE试用版吗?早上好Bruno,我试着用特定的库运行应用程序,我有同样的例外。我必须配置其他东西吗?我将库添加到项目中,仅此而已。你知道我为什么有这个例外吗?它对我们有用。请看,您必须像集成任何其他库一样,将iText集成到APK中。在将jar添加到项目中之后,您的APK应该更大。有关不同产品的比较,请参阅。iText可以产生最大的应用程序文件大小,但比其他产品快得多。
package mx.gob.campeche.sit.web.reportes;
import java.io.IOException;
import java.io.OutputStream;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import mx.gob.campeche.sit.doc.recibo_oficial.ReciboOficial;
@WebServlet("/reciboOficial")
public class ReporteReciboOficialServlet extends HttpServlet {
@Inject
ReciboOficial reciboOficial;
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpServletRequestWrapper srw = new HttpServletRequestWrapper(request);
String folio = "";
if (request.getParameterMap().containsKey("folio")) {
folio = request.getParameter("folio");
System.out.println("contenido" + folio);
}else
if (request.getParameterMap().containsKey("numero")) {
folio = request.getParameter("numero");
System.out.println("contenido" + folio);
}else{
throw new ServletException("No ingreso parametro");
}
byte[] pdfData = reciboOficial.crearReciboOFicialCajas(folio, srw.getRealPath(""));
response.setContentType("application/pdf");
response.reset();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline; filename=\"" +"samplePDF2.pdf" +"\"");
OutputStream output = response.getOutputStream();
output.write(pdfData);
output.close();
}
this is small example, this help