I'm trying to create PDF using iText in Java. When i tried to write HTML tags in my PDF it created like <a href="https://www.google.co.in">Google</a>
instead of Google(as a link). After searching net i tried using XMLWorkerHelper
. But my eclipse giving error as The method parseXHtml(PdfWriter, Document, InputStream) from the type XMLWorkerHelper refers to the missing type PdfWriter
I'm not getting what is this error.
try {
String k = "<html><body> This is my Project </body></html>";
OutputStream file = new FileOutputStream(new File("C:\\Test.pdf"));
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, file);
document.open();
InputStream is = new ByteArrayInputStream(k.getBytes());
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
document.close();
file.close();
} catch (Exception e) {
e.printStackTrace();
}
I want to know which PdfWriter i should use. I'm using xmlworker-5.4.1.jar
jar file.
Looking at the
com.itextpdf.tool.xml.XMLWorkerHelper
source code, it looks like it is depending oncom.itextpdf.text.pdf.PdfWriter
which is part of theitextpdf-5.4.1.jar