This project is read-only.

User export HTML content to Word

Topics: Core, Customizing Orchard, General, Writing modules
Dec 17, 2011 at 9:58 AM

Hi all,

I want to create a feature in Orchard where i can have the user export/download the content in word format from a hyperlink or button, but not for all content items just for some so when creating a content item it should present a checkbox yes/no user export.

I need help dont know where to start or if this feature is already there or in a module



Dec 17, 2011 at 10:48 AM

You can certainly use the Office API in C# to generate Word files. The problem is, you'd first have to parse the HTML content to work out exactly what document elements to create (and that's the really hard part).

Also; exactly what do you want to export - the entire page, including layout and all? Or just the body content (presumably with heading)? Images as well?

The question to consider is what aim are you trying to achieve; why do you need your content in Word, and perhaps there's a better way to reach the same end.

Also don't forget that Word can easily import HTML, which saves you the whole thorny task of parsing and converting it yourself!

Dec 17, 2011 at 11:01 AM

hi pete,

what i want to achive is the following:

create a 'page' then what you type in the editor so the text in the body needs to be exported so no layout of the website etc just the editors data and i want this on the front end for registererd customers. its a feature where people can online read contracts/documents (law) and then export to Word to use it further.

hope this makes my goal clearer...


regards Sander

Dec 17, 2011 at 11:37 AM

You may find it easier to just create the documents first in Word, then copy and paste them into the HTML body editor, and finally attach the original files for download. Any amount of automatic conversion is unlikely to give completely satisfactory results (in my opinion).

Dec 17, 2011 at 11:44 AM

i agree with you, i can upload the Word docs with the media manager but then it would be very if the ck editor would have access to those files uploaded with media manager like tiny mce has, any idea on how i can achieve this?

Dec 17, 2011 at 2:41 PM
Edited Dec 17, 2011 at 2:42 PM

Just happens I'm coordinator on the CKEditor module ;)  Media Picker integration is a much-desired feature but I haven't yet had chance to do it. There would still be a problem there as the Media Picker only really supports images.

There is another solution, which is something I've used myself (for an intranet site I built) which is a combination of two of my modules - Media Garden and Mechanics. This allows you to create Document content items from uploaded files using Media Garden, then attach them to your pages using Mechanics relationships; the download links will be rendered at the bottom below your body content. It works but it's all a bit clunky right now, I'm planning some big improvements but it's taking me some time.