Sathesh S
Sathesh S

Reputation: 1323

XMLWorkerHelper giving error in Java

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.

Upvotes: 0

Views: 2388

Answers (1)

Dror Bereznitsky
Dror Bereznitsky

Reputation: 20376

Looking at the com.itextpdf.tool.xml.XMLWorkerHelper source code, it looks like it is depending on com.itextpdf.text.pdf.PdfWriter which is part of the itextpdf-5.4.1.jar

Upvotes: 2

Related Questions