Page 1 of 1

ConvertInXHTMLFile sample throws NoSuchMethodError

PostPosted: Fri Aug 31, 2012 11:31 pm
by n_blessing
Hi,

Im trying to create docx from xhtml using the ConvertInXHTMLFile sample provided. I used the default jars from docx4j-2.8.0.zip. However its throwing

Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(I)[I
at org.docx4j.org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:730)
at org.docx4j.org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.<init>(ITextFontResolver.java:661)
at org.docx4j.org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:461)
at org.docx4j.org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:441)
at org.docx4j.org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:41)
at org.docx4j.org.xhtmlrenderer.docx.DocxRenderer.<init>(DocxRenderer.java:133)
at org.docx4j.org.xhtmlrenderer.docx.DocxRenderer.<init>(DocxRenderer.java:85)
at org.docx4j.convert.in.xhtml.XHTMLImporter.convert(XHTMLImporter.java:377)
at ConvertInXHTMLFile.main(ConvertInXHTMLFile.java:71)

Im Struck here... Please help

Re: ConvertInXHTMLFile sample throws NoSuchMethodError

PostPosted: Sat Sep 01, 2012 8:16 am
by jason
What is the input XHTML?

Re: ConvertInXHTMLFile sample throws NoSuchMethodError

PostPosted: Mon Sep 03, 2012 5:41 pm
by n_blessing
Hi Jason,

Thanks for your reply..this is the input xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator"
content="HTML Tidy for Java (vers. 27 Sep 2004), see www.w3.org" />
<title></title>
</head>
<body>
<p><strong>Hi <span
style="text-decoration: underline;">Welcome</span> to</strong>
<strong><em>tinyMCE</em></strong> <strong>editor</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span
style="font-size: 12pt;">€&amp;&cent;&yen;&copy;&reg;œ&euml;</span></p>
<p><strong>

</strong> <span
style="font-size: 12pt;">€&amp;&cent;&yen;&copy;&reg;œ&euml;
testing<a href="http://google.com"
target="_blank">few</a>features<sub>here</sub></span></p>
<p><span style="font-size: 12pt;">&nbsp;</span></p>
<p
style="left: 697px; top: 52px; width: 100px; height: 100px; position: absolute;"><span
style="font-size: 12pt;">Again<sup>here</sup>

</span></p>
<h1><span style="font-size: 12pt;">And</span></h1>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><!-- pagebreak --></p>
<p>&nbsp;</p>
<p><span
style="font-size: 12pt;">2012-08-31&nbsp;&nbsp;&nbsp;&nbsp;
19:58:27 &nbsp;</span></p>
<blockquote>
<ol>
<li><span style="font-size: 12pt;">some text</span></li>
<li>Test it</li>
<li>Here Too<span style="font-size: 12pt;">

</span></li>
</ol>
</blockquote>
</body>
</html>


However i tried with a simple xhtml as below but still the same error.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
Wikibooks
</title>
</head>
<body>
<p>
Wikibooks is a great website.
</p>
</body>
</html>


Please help..

Re: ConvertInXHTMLFile sample throws NoSuchMethodError

PostPosted: Mon Sep 03, 2012 6:03 pm
by jason
Works for me. Do you have itext 2.1.7 on your class path?

Also, you might want to use http://www.docx4java.org/docx4j/docx4j- ... 120902.jar

Re: ConvertInXHTMLFile sample throws NoSuchMethodError

PostPosted: Mon Sep 03, 2012 8:48 pm
by n_blessing
Thanks jason ..Works like a charm!!

Actually i was missing itext-2.1.7.jar in my classpath.

Another clarification..Will docx4j support these properties while converting from xhtml to docx

1. Underline
2. Font Color
3. Tables
4. Symbols

Re: [docx4j-user] ConvertInXHTMLFile sample throws NoSuchMet

PostPosted: Mon Sep 03, 2012 8:57 pm
by jason
> Thanks jason ..Works like a charm!!
>
> Actually i was missing itext-2.1.7.jar in my classpath.

Good to hear :-)

> Another clarification..Will docx4j support these properties while
> converting from xhtml to docx
>
> 1. Underline

Yes

> 2. Font Color

Currently, no, but seems to be a popular request; you can vote for it
at http://docx4j.userecho.com/topic/124939-/

> 3. Tables

Yes

> 4. Symbols

Depends what you mean. I think if your XHTML is encoded using UTF-8,
a character ought to be preserved.

cheers .. Jason
_______________________________________________
docx4j-user mailing list
docx4j-user@docx4java.org
http://docx4java.org/cgi-bin/mailman/li ... ocx4j-user