Document document = new Document(PageSize.A4, ml, mr, mt, mb);
PdfWriter writer=PdfWriter.getInstance(document, response.getOutputStream());
String sc_na=request.getParameter("school_name");
String name=sc_na;
writer.setPageEvent(new HeaderAndFooter(name));
document.open();
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
//HTMLWorker htmlWorker = new HTMLWorker(document);
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/elect", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from test3");
List arrlist = new ArrayList();
while(rs.next()){
String xa =rs.getString("display");
if(xa.equals("1")){
arrlist.add(rs.getString("question_text"));
}
}
Collections.shuffle(arrlist);
for(int i=0;i<nb;i++){
String str = (String) arrlist.get(i);
worker.parseXHtml(writer, document, new StringReader("<br>"));
worker.parseXHtml(writer, document, new StringReader(str));
}
document.close();
这是我的代码片段。使用我将所有数据放在一个列中。我应该怎么做才能进入多个列。我猜一种方法是使用 PDFptable,但我如何在此处应用它。请帮助。