AnsweredAssumed Answered

Insert Freemarker in MS-Word generated HTML document

Question asked by fhomasp on Apr 21, 2008

Perhaps, or to say I hope, someone has tried and succeeded in doing this and can give me some pointers.

Basically I have an XML document in the repository that needs to get its info in a HTML document.  After that it gets transformed to .pdf but that's done through Alfrescos own transformation interface referenced by an inbound content rule.  This last part is not really important for my question unless someone can point me to its relevance.

So I thought I'd just take the Word document and save it as a html file.  A directory gets made with images and an html file which references parts of the image files and xml file list in the folder.

I opened the html file generated and noticed its size, rather biggish.  Obviously I have no clue to what's needed and what's not.  I did remove the document properties in the html file, placed some freemarker syntax below the </head> tag and worked my way down to test three properties.  The code:

<html xmlns:v="urn:schemas-microsoft-com:vml"

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="images/filelist.xml">
<link rel=Edit-Time-Data href="images/editdata.mso">
<!–[if !mso]>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}

<!— Here are a whole bunch of CSS styles defined –>

<!– I placed some Freemarker syntax here below this marker –>

<body lang=EN-US link=blue vlink=purple style='tab-interval:36.0pt'>
<#if document.mimetype == "text/xml">
   <#assign dom=document.xmlNodeModel>
       <#list as o>
       <#if o.@class=="data.PersonalData">

<!– From here on the generated stuff continues until I find properties that need inserting.  The freemarker data is found at the bottom of the table, this is one property  –>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 align=left
.05pt;mso-padding-alt:0cm 5.4pt 0cm 5.4pt'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:19.25pt'>
  <td width=104 style='width:77.7pt;border:solid #667D78 1.0pt;mso-border-alt:
  solid #667D78 .5pt;background:#E2001A;padding:0cm 5.4pt 0cm 5.4pt;height:
  <p class=MsoNormal style='mso-element:frame;mso-element-frame-hspace:9.0pt;
  column;mso-element-top:.05pt;mso-height-rule:exactly'><span lang=EN-GB
  style='mso-ansi-language:EN-GB'>First Name:<o:p></o:p></span></p>
  <td width=253 style='width:189.7pt;border:solid #667D78 1.0pt;border-left:
  none;mso-border-left-alt:solid #667D78 .5pt;mso-border-alt:solid #667D78 .5pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:19.25pt'>
  <p class=MsoNormal style='margin-top:3.0pt;margin-right:0cm;margin-bottom:
  column;mso-element-top:.05pt;mso-height-rule:exactly'><span lang=EN-GB
             <#list o.void as v>
                <#if v.@property=="firstName">

<!– I tried two more properties but its the same thing as above, pretty much.  I then ended with finding the </body> tag and wrote the next freemarker stuff above it.

    No XML file


So obviously between the <#if> tag and </#if> tag defining the freemarker stuff there is a whole lot of html-like code to be found.

I opted for MS Word to do the transformation between .doc and html as OpenOffice writer couldn't save much of the layout.  But perhaps I should just try with the openoffice stuff as it's 100 times smaller with cleaner html code.

But if anyone who has ever done this kind of thing before can tell me how to do all that and save the layout It'd be greatly appreciated.