Why does using itext xmlworker in java giving a strange error?

42 Views Asked by At

i'm trying to get byte array of html string after convert this string to pdfwriter. When i run into XMLWorkerHelper.getInstance().parseXHtml, it return weird error: java.lang.NumberFormatException: For input string: "100%". I have searched a few places but to no avail, here my function

byte[] convertHtmlToPdfBytes( String htmlString ) {
    Document document = new Document();

    ByteArrayOutputStream outp = new ByteArrayOutputStream();

    PdfWriter writer = PdfWriter.getInstance(document, outp);
    document.open();

    InputStream inp = IOUtils.toInputStream(htmlString);
    XMLWorkerHelper.getInstance().parseXHtml(writer, document, inp);

    document.close();

    return outp.toByteArray();
}
0

There are 0 best solutions below