我尝试使用iText从html创建pdf:
String html= "<table style=\";border: 2px solid black\">"
+ "<tr>"
+ "<td>Column 1</td>"
+ "<td style=\";border: 1px solid red; width: 80mm\";>Column 2</td>"
+ "</tr>"
+ "</table>";
Document document = new Document(PageSize.A4);
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("htmlFahrplan.pdf"));
pdfWriter.setLinearPageMode();
pdfWriter.setFullCompression();
document.addCreationDate();
document.open();
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.parse(new StringReader(html));
document.close();
pdfWriter.close();
但生成的pdf没有样式设置:没有边框和 每列的列宽相同!
有没有人知道如何改变这个?