Allow for formatted raw HTML to be included in DOCX

Allow for formatted raw HTML to be included in DOCX

Postby Otto » Sun Jan 14, 2018 7:11 pm

Hello,
in case someone needs formatted raw HTML to be included in DOCX.
Best regards,
Otto

Steps

Docx- file rename to Zip and unzip

Copy your MHT file to the word directory of the zip

Search for placeholder in document.xml and replace with
<w:altChunk r:id="htmlDoc" />
word/document.xml - main XML document containing reference to imported file ("w:altChunk" element)


altChunk (Anchor for Imported External Content)
This element specifies a location within a document for the insertion of the contents of a specified file containing external content to be imported into the main WordprocessingML document.
The altChunk element specifies that the external content targeted by the relationship with an ID of altChunk1 must be imported at the beginning of the document.


<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/htmlDoc.html" Id="htmlDoc" />
The corresponding relationship part item shows that the file to be imported is located next to the main document and is named import.htm. end example]


[Content_Types].xml - contains declaration of "altChunk" content type (mime type - "text/html"; mime type for MHTML is "message/rfc822"):
<Override PartName="/word/htmlDoc.html" ContentType="text/html"/>

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 5994
Joined: Fri Oct 07, 2005 7:07 pm

Re: Allow for formatted raw HTML to be included in DOCX

Postby Ruth » Sat Jul 31, 2021 10:29 am

Dear Otto/Dad :-)

this sounds very interesting...please be so kind as to share an example before and after of the document.xml?

by "placeholder" you mean a spot, that you chose, where the raw html should be put?

i am very interested in this...also i want to check what happens to the format...a client uses black background for his docx...now i want to see if I can leave this info blank in the mht so that it get the background from the docx...

kind regards
ruth
User avatar
Ruth
 
Posts: 135
Joined: Fri Dec 07, 2007 1:26 pm

Re: Allow for formatted raw HTML to be included in DOCX

Postby Antonio Linares » Sat Jul 31, 2021 5:11 pm

Dear Otto,

I admire your energy and passion :-)

a big hug
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 15 guests