wooio / htmltopdf-java

An HTML to PDF conversion library written in Java, based on wkhtmltopdf.
MIT License
173 stars 97 forks source link

HTTP Status 500 ? Interval Server Error when generating PDF #43

Closed mavyfaby closed 3 years ago

mavyfaby commented 4 years ago

I'm using Apache Tomcat 9 as a web server for my web application.

I tested the example code of yours in the README:

import io.woo.htmltopdf.HtmlToPdf;
import io.woo.htmltopdf.HtmlToPdfException;
import io.woo.htmltopdf.HtmlToPdfObject;
...
String url = "http://127.0.0.1:8080/Management/UserDayReport?userid1=1&range1=1590940800&username1=Maverick+Fabroa&numdays1=25&isExport=false";
String absPath = "/var/lib/tomcat9/webapps/attendance/Testing.pdf";

boolean status = HtmlToPdf.create().object(HtmlToPdfObject.forUrl(url)).convert(absPath);
...

gives me Internal Server Error:

Type Exception Report

Message Servlet execution threw an exception

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet execution threw an exception
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.NoClassDefFoundError: com/sun/jna/Pointer
    io.woo.htmltopdf.HtmlToPdf.convert(HtmlToPdf.java:246)
    com.wmdc.attendance.GeneratePDF.doGet(GeneratePDF.java:64)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Note The full stack trace of the root cause is available in the server logs.

How do I fix this? Thank you