Page 1 of 1

Problems in import Html

PostPosted: Fri Oct 19, 2012 12:34 am
by Candeloro
This is my first use of docx4j
I must convert html file to docx, I used the XHTMLImportDocument;
the docx generated has lost the layout defined by css,
my Html is
Code: Select all
<!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 content="text/html; charset='UTF-8'" http-equiv="Content-Type" /><link href="css/editor.css" type="text/css" rel="stylesheet" /> <title>WebSuite 4</title>
</head><body><p style="text-align: center;"><strong>TRIBUNALE DI ROMA</strong></p>
<p style="text-align: center;"><strong>ATTO DI CITAZIONE</strong></p>
<p style="text-align: center;"><strong>IN FATTO</strong></p>
<p style="text-align: justify;">Il signor Scategni Giuseppe , nato a Roma(RM), il 14/10/1959, residente in Roma (RM) in Via della Bufalotta, 378, (C.F.SCTGPP59R14H501I)</p>
<p style="text-align: justify;">Il signor Scategni Stefano , xxxx nato a Roma(RM), il 23/09/1963, residente in Ladispoli (RM) in Piazza del comune, 29, (C.F.SCTSFN61P23H501Q)</p>
<p>Esposizione dei fatti articolati per punti specifici.</p>
<p style="text-align: center;"><strong>IN DIRITTO</strong></p>
<p>Luogo e data</p>
<p>Avv. (firma)</p></body></html>

i think depends on my html page
can you help me thanks

Re: Problems in import Html

PostPosted: Fri Oct 19, 2012 4:23 am
by jason
Is your file css/editor.css available? (What do the logs say?)

As a diagnostic, is the CSS used as you expect if you put it into the XHTML inside a <style> element?

Re: Problems in import Html

PostPosted: Fri Oct 19, 2012 6:38 pm
by Candeloro
This is the css
Code: Select all
body {
   background-color: #FFFFFF;
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 14px;
   max-width:21.001cm;
   margin-top:2cm;
   margin-bottom:4.001cm;
   margin-left:3cm;
   margin-right:3cm;
   line-height: 1cm;
}

p {
   margin:0;
   padding:0;
   text-align: justify;
   line-height: 1cm;
}

td {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 14px;
}
.campo{
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 14px;
   background-color:  #00FF00;
}
.camponomod{
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 14px;
   background-color:  #FFCC33;
}
pre {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 14px;
}

.example1 {
   font-weight: bold;
   font-size: 14px;   
}

.example3 {
   font-weight: bold;
   font-size: 12px;
   color: #FF0000
}

.tablerow1 {
   background-color: #BBBBBB;
}

thead {
   background-color: #FFBBBB;
}

tfoot {
   background-color: #BBBBFF;
}

th {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 13px;
}


Re: Problems in import Html

PostPosted: Fri Oct 19, 2012 7:35 pm
by jason
Fine, but did docx4j find it via the link?

And what is the answer to my question "is the CSS used as you expect if you put it into the XHTML inside a <style> element?"

Re: Problems in import Html

PostPosted: Fri Oct 19, 2012 8:47 pm
by Candeloro
I test convert via Url
Code: Select all
URL url = new URL("http://www.ernosroma.it/Test/Test.html");
   
   wordMLPackage.getMainDocumentPart().getContent().addAll(
         XHTMLImporter.convert(url , wordMLPackage) );

the link http://www.ernosroma.it/Test/Test.html is fine
thanks for your attention

Re: Problems in import Html

PostPosted: Mon Oct 22, 2012 5:14 pm
by Candeloro
If I put in the html page elements like css <span style="font-family: helvetica; font-size: x-large;"> the page docx these are not interpreted,
also vowels with accents are not recognized; can you help me?
P.S
sorry for my bad English