我想用HTML代码设置PDF标题。以下是代码:
public void createHeader(Document pdfDocument, String k) throws IOException {
k = "<!DOCTYPE html><html><body><h2>Spectacular Mountain</h2><img src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Phoenicopterus_ruber_in_S%C3%A3o_Paulo_Zoo.jpg"></body></html>";
StringReader reader = new StringReader(k);
HTMLWorker htmlWorker = new HTMLWorker(pdfDocument);
htmlWorker.parse(reader);
HeaderFooter header = new HeaderFooter(new Phrase(reader.toString()), false);
document.setHeader(header);
}
我的代码有什么问题?我应该添加什么吗?