0
플라잉 받침판을 사용하여 PDF로 변환하려는 jsp 파일이 있습니다. 여기 jsp를 플라잉 받침 접시를 사용하여 PDF로 변환
<%@page contentType="text/html" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net/el" %>
<!DOCTYPE html>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="testDBForm" action="<%=basePath%>/TestDatabase" method="post" onsubmit="return true">
<input type="submit" id="btnInsert" value="btnInsert" name="btnInsert" text="INSERT"/>
<input type="submit" id="btnSelect" value="btnSelect" name="btnSelect" text="SELECT"/>
<input type="submit" id="btnDelete" value="btnDelete" name="btnDelete" text="DELETE"/>
<input type="submit" id="btnUpdate" value="btnUpdate" name="btnUpdate" text="UPDATE"/>
</form>
<c:if test="${not empty message}">
<h1>${message}</h1>
</c:if>
<c:if test="${not empty insert}">
<h1>Insert: ${message}</h1>
</c:if>
<c:if test="${not empty select}">
<h1>Select: ${message}</h1>
</c:if>
<c:if test="${not empty update}">
<h1>Update: ${message}</h1>
</c:if>
<c:if test="${not empty delete}">
<h1>Delete: ${message}</h1>
</c:if>
</body>
</html>
내가 PDF로 HTML을 구문 분석을 위해 사용하고있는 서블릿 코드 : 다음은 JSP 파일입니다
protected void processRequest(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/pdf");
String inputFile = "D:\\03072014\\src\\main\\webapp\\includes\\testDatabase.jsp";
String url="";
try {
url = new File(inputFile).toURI().toURL().toString();
} catch (MalformedURLException ex) {
Logger.getLogger(HtmlToPdfTaxCardConvertor.class.getName()).log(Level.SEVERE, null, ex);
}
OutputStream os=null;
try {
os = response.getOutputStream();
} catch (IOException ex) {
Logger.getLogger(HtmlToPdfTaxCardConvertor.class.getName()).log(Level.SEVERE, null, ex);
}
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
try {
renderer.createPDF(os);
os.close();
} catch (DocumentException ex) {
Logger.getLogger(HtmlToPdfTaxCardConvertor.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex) {
Logger.getLogger(HtmlToPdfTaxCardConvertor.class.getName()).log(Level.SEVERE, null, ex);
}
} }
나는 예외 얻었다는
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
누군가 저를 도울 수 있고이 종류의 html 페이지에서 pdf를 창조하는 것이 가능합니다