CookieMonster
CookieMonster

Reputation: 11

Problem with generating pdf file

I'm trying to generate pdf file from xhtml using Flying Saucer do you have any idea why this code always throwx exception?

import org.xhtmlrenderer.pdf.ITextRenderer
import com.lowagie.text.DocumentException
private void testconfiguration(String taskId) throws IOException, DocumentException {
      String inputFile = "/home/marcin/firstdoc.xhtml";
      String url = new File(inputFile).toURI().toURL().toString();
      String outputFile = "/home/marcin/firstdoc.pdf";
      OutputStream os = new FileOutputStream(outputFile);
      ITextRenderer renderer = new ITextRenderer();
      renderer.setDocument(url);
      renderer.layout();
      renderer.createPDF(os); // this line generates Exception
      os.close();
}

Upvotes: 0

Views: 2689

Answers (1)

JB Nizet
JB Nizet

Reputation: 692081

You probably have two incompatible versions of libraries in your classpath (i.e. the xhtmlrenderer library probably expects a version of the lowagie library that is not the one you're using).

Upvotes: 1

Related Questions