create new tag
, view all tags

MsOfficeAttachmentsAsHTMLPluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on MsOfficeAttachmentsAsHTMLPlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below

Feedback on MsOfficeAttachmentsAsHTMLPlugin

Oh, it only works for word files right now. Happy Easter!

http://chicago.sourceforge.net/xlhtml/ or similar might be suitable to get it to work for Excel. Please contribute if you get this to work.

-- MartinCleaver - 11 Apr 2004, 02 May 2005

[how to use the Plugin]
thank you for that hint: BeforeAttachmentSaveHandler.
Do I have a chance to find information like that on my own?

I tried to patch, but it didn't work for Plugins.pm:

Hunk #1 FAILED at 30.
Hunk #2 FAILED at 49.
Hunk #3 FAILED at 112.
Hunk #4 succeeded at 134 (offset -36 lines).
Hunk #5 succeeded at 143 (offset -36 lines).
Hunk #6 FAILED at 151.
Hunk #7 succeeded at 156 (offset -51 lines).
Hunk #8 FAILED at 294.
Hunk #9 succeeded at 355 (offset -125 lines).
Hunk #10 FAILED at 477.
Hunk #11 FAILED at 491.
7 out of 11 hunks FAILED -- saving rejects to file Plugins.pm.rej

My Plugins.pm had the version 1.010 instead of 1.020, so the afterSaveHandler or all the =pod elements for example were missing.

Well, I patched carefully by hand, which was fine: the Plugin works!

-- SusanneRuppel - 30 Aug 2004

I just tried it on my Cairo install, but it does not work. it destroys the existing page and replaces it with:

This text was automatically generated from the attachment FloorplanningBudgeting.doc
Not Found

The requested URL /twiki/pub/Proj/PhysicalIntegration/_MsOfficeAttachmentsAsHTMLPlugin/FloorplanningBudgeting.doc.html was not found on this server.
Apache/2.0.46 (Tao Linux) Server at server.company.com Port 80

By looking at the timestamps, I was wondering if this plugin is supposed to work with Cairo (or has it not yet been updated ? )


-- GillesEricDescamps - 27 Oct 2004

I've not yet installed this for Cairo so I don't know its status. That said, I expect to look at it within the next couple of days.

-- MartinCleaver - 27 Oct 2004

You need to install wvHtml on Windows before it works on Windows XP. Available at: http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=21335&release_id=284320

-- ChrisKlaus - 31 Dec 2004

My need subsided again, sorry :/

For anyone wanting to get this to work with powerpoint, http://www.oooforum.org/forum/viewtopic.php?t=9437&highlight=convert+html could save us some time.

And http://www.oooforum.org/forum/viewtopic.php?t=4998 is worth looking at too.

-- MartinCleaver - 17 Jan 2005

The code also mentions Perlmagic and Imagemagic without making it clear whether these are two seperate products or mentioning them on the plugin page - I only found out about them from another user's comments. Being a CPAN novice I would at least like the name of both the modules (e.g. Image::Magic is one of the modules, what is the name of the other - if it a seperate model. And the code is not the place to list pre-requisites (and if it isn't a pre-requisite why does the code say it is.)

Given the discussions I have read re: WYSIWYG, MS Office integration and achieving management buy-in, and therefore my percieved popularity of this aspect, I imagine getting this more clearly documented would have great benefit (and yes, when I get it working I will add my tuppence worth to this - I'm merely commenting 'a priori' as it were).

-- SteveMayes - 08 Feb 2005

Error: Unsupported content type: application/msword. (Must be text/html, text/plain or text/css)

-- BruceRProchnau - 19 Feb 2005

I'm sorry I am currently unable to dig in and resolve your issues, but I do encourage you to collaborate together to solve them. I too see MS office compatibility as key and hope to see this developed further. WRT extending functionality to PPT and Excel:

http://tom.library.upenn.edu/convert/sofar.html says:

http://freshmeat.net/search/?q=excel+html&section=projects&Go.x=0&Go.y=0 might be useful, especially http://freshmeat.net/projects/xlhtml/

-- MartinCleaver - 23 Feb 2005

Thanks Martin, will check that out. I am intensely interested in making this work in a simple way. It would be a very sensible business buy in extending TWiki's usefulness. I am working on it as time permits. It seems even when Im unemployed I still lack time...lol

I can see writing a document in Word, and publishing directly into TWiki as a Topic, one click (well, maybe two).

Maybe I can incorporate it somehow with Movabletype blog addon on www.movabletwiki.com, but just in twiki alone would be best. A weblog IN twiki don't hurt tho :-). Also not positive about using word lol have to use antiword or something as well...hmm

-- BruceRProchnau - 23 Feb 2005

I'm trying to get this plugin working on OpenBSD. When I upload a sample work document I get:

*This text was automatically generated from the attachment TestWordDocument.doc

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.*

The error_log in my apache spits this out:

[Fri Mar 4 13:05:57 2005] view: Argument "cvs.secureops.com" isn't numeric in subroutine entry at /usr/libdata/perl5/i386-openbsd/5.6.1/Socket.pm line 442.

Now, I've install mod_auth_radius and am using apache 1.3.24 and I made sure all the files were owned and readable by the httpd (www) user.

Anybody have any clue?

-- PatrickEthier - 04 Mar 2005

This plugin is not pre-installed as the above states, it does need installing. Windows users should note the wvHTML dependency mentioned below.

-- SteveMayes - 17 Mar 2005

I removed this from the Plugin topic:

(This plugin is preinstalled, you do not need to install it.)

Martin: Please consider this topic change in the next release.

-- PeterThoeny - 18 Mar 2005

Thanks Peter, sorry Steve.

You've fixed it for me, Peter. I use BuildContrib: this uses the TWiki.org version as the authoritative topic text.

-- MartinCleaver - 19 Mar 2005

I wrote this the other day: it extracts all charts and all worksheets with a defined print area into a PPT.

I am clear that this could be used to automatically convert an XLS into a set of jpegs and I welcome ideas code contributions.

This is Excel VBA, with the Powerpoint reference loaded.

Sub ExcelToPowerPoint()
Dim xlObj As Object
Dim xlsheet As Object
Dim xlChart As Object
Dim ppObj As Object

'Set xlObj = Workbooks(2)
Set xlObj = CreateObject("Excel.application")
Set ppObj = CreateObject("PowerPoint.application")

Dim xlsFileName As String
xlsFileName = Application.GetOpenFilename("")
xlObj.Visible = True

ppObj.Visible = -1 '=msotrue

xlObj.Workbooks.Open Filename:=xlsFileName, UpdateLinks:=0, ReadOnly:=True
ppObj.Presentations.Add -1 '=msotrue

For Each xlsheet In xlObj.Sheets
    If copySheet(xlsheet) Then
       ppObj.ActivePresentation.Slides.Add ppObj.ActivePresentation.Slides.Count + 1, 12
       ppObj.ActiveWindow.View.GotoSlide ppObj.ActivePresentation.Slides.Count
       pasteAsEnhancedMetaFile ppObj.ActivePresentation.Slides(ppObj.ActivePresentation.Slides.Count)
'       slideObj.Shapes.Placeholders(1).TextFrame.TextRange.Text = "foo"
    End If


End Sub

Sub pasteAsEnhancedMetaFile(slideObj As Object)
    Debug.Print slideObj.Name

    With slideObj
        .Layout = ppLayoutObject
        .Shapes("Rectangle 3").Select
        slideObj.Application.ActivePresentation.Windows(1).View.PasteSpecial DataType:=ppPasteEnhancedMetafile
    End With

End Sub

Function copySheet(xlsheet As Object) As Boolean
' Debug.Print xlSheet.Workbook.Name
Dim ans As Boolean

 Debug.Print "  " & xlsheet.Name
 If xlsheet.Type = xlWorkSheet Then
    Debug.Print "   Worksheet"
    ans = copyActivePrintArea(xlsheet)
    Debug.Print "   Assuming Chart (" & xlsheet.Type&; ")"
    ans = copyChart(xlsheet)
 End If
 copySheet = ans
End Function

Function copyActivePrintArea(xlsheet As Object) As Boolean
    Dim printAreaRange As String
    Dim message As String
    printAreaRange = xlsheet.PageSetup.PrintArea
    If (printAreaRange = "") Then
        message = "    Ignored " & xlsheet.Name & " as there is no set print area"
        Debug.Print message
        Set MyData = New DataObject
        MyData.SetText Err
        ans = False
        Dim hadGridlines As Boolean
        hadGridlines = getGridlines(xlsheet)
        xlsheet.Range(printAreaRange).CopyPicture Appearance:=xlScreen, Format:=xlPicture

        Debug.Print "    Copied"
        putGridlines xlsheet, hadGridlines
        ans = True
    End If
    copyActivePrintArea = ans
End Function

Function copyChart(xlsheet As Object) As Boolean
    xlsheet.CopyPicture Appearance:=xlScreen, Format:=xlPicture
    Debug.Print "   Copied chart " & xlsheet.Name
    copyChart = True
    Exit Function
    Debug.Print "Failed!"
    copyChart = False
End Function

Function getGridlines(xlsheet As Worksheet) As Boolean
    getGridlines = ActiveWindow.DisplayGridlines

End Function

Sub putGridlines(xlsheet As Worksheet, flag As Boolean)
    ActiveWindow.DisplayGridlines = False

End Sub

-- MartinCleaver - 19 Mar 2005

Will it be possible to search through these HTML files? Without search it only helps a little bit.

-- MarkusLitz - 27 Apr 2005

Yes, it ends up in the content pane so is fully searchable.

-- MartinCleaver - 02 May 2005

I try'd it several times, it does not search. The html File is only included, maybe this is the reason.

-- MarkusLitz - 03 May 2005

Oh. Good point. If you are running on Windows and use the IndexServerSearchForMsIisAddOn searches do actually search attachments.

-- MartinCleaver - 05 May 2005

No, i use Linux (Debian Woody). I solved the problem by using the Plucene search plugin. But one thing to do: many by wv converted documents have problems with german umlauts. It would be great if this plugins make a "recode -f UTF-8..ISO-8859-1 xxx.html" or somthing by default.

-- MarkusLitz - 06 May 2005

Feel free to make a new release, Markus.

-- MartinCleaver - 06 May 2005

Does this plugin work for anyone? It sure would be nice if the plugin topic as delivered by the installation zip file would contain even a few morsels to get beyond this kind of error:

Not Found The requested URL /twiki/pub/Sandbox/MsWordDoc/_MsOfficeAttachmentsAsHTMLPlugin/TestWordDoc.doc.html was not found on this server.

I gather that the plugin didn't generate the .html file since I can't find one anywhere on my server. Is this related to the comments elsewhere that I need ImageMagick and the associated Image::Magick ?

As I can only imagine how important this plugin is to people, I'll try to post some of my findings. I'll proceed with debugging and seeing what I can find. But if anyone has had success with this plugin and a simple, vanilla install of TWiki, please post how you got it to work.

-- DavidMain - 07 May 2005

Turns out it wasn't too difficult to get this plugin to work. To figure it out, I set the plugin's DEBUG preference to 1 and was then able to observe immediately in debug.txt that it was calling /usr/bin/wvHtml (and not checking any return codes to see if the call to it was successful!). Not recognizing this executable, I Googled on it and discovered the nifty wvWare Project. Indeed, after reading a bit, it is clear now that wvHtml is at the heart of this plugin.

To fix things, I did the following:

  • Install the "wv" tools. Under FreeBSD you can find this project in the ports collection under the textproc category. The project installed easily for me.

  • FreeBSD doesn't install the executables to the same path as used by the plugin. After debating with myself for a few moments about whether to alter the code or put in a symbolic link to make the hard-coded path to wvHtml work, I decided to put in the link since it involved less work and would remain in place in the event that I install an upgrade to the plugin someday in the future.

A surprising amount of formatting is preserved from the original document:

  • Underlining, bold, italics
  • Numbered and bulleted lists
  • Indentation
  • Limited font size changes (i.e., larger headings in the source document creates a slightly larger font size in the converted HTML)
  • An attempt is made to convert Word tables into HTML equivalents

I also discovered--to my surprise--that wvHtml was able to handle documents produced by OpenOffice and NeoOffice/J. Sadly, Apple's iWork Pages program doesn't seem to export files that work with wvHtml despite the fact that they are supposed to be Word-compatible (and Word can even open them).


  • The main plugin page does not mention the wvWare requirement. This plugin won't work until you install that project (and all of its dependencies).

  • The plugin hard-codes the path to wvHtml, which may not be the location where your executables install. You may need to create a link as I did.

  • ChrisKlaus's comments above are misleading. You need to install wvWare (which includes the wvHtml executable) no matter what operating system you are running (unless it already is present on your server).

I hope this info is helpful to someone someday!

-- DavidMain - 08 May 2005

I'd like this to work for powerpoint and excel too. http://nebuchadnezzar.zion.cz/xlhtml.php might help but I have no plans as yet to try it.

-- MartinCleaver - 03 Jun 2005

A packaging issue is described at Support.MsOfficeAttachmentPluginQuestion

-- PeterThoeny - 07 Jun 2005

A question about this plugin: once installed, does it always convert doc files, or can it be invoked by some TWikiVariable? E.g. %Attachment-to-html{attachment1, attachment3} or something?

  • It always converts

Also, is it possible to have seperate 'standard' TWiki content on the page? Can you e.g. have discussions underneath an included ConvertedDoc?

  • No.

Third, what happens when two doc files are attached to a topic?

  • The second replaces the appearance of the second.

Just curious before I install, I've only got the live server to play with at the moment. Thanks * Fair enough

-- JosMaccabiani - 13 Jun 2005 (answers by MartinCleaver - 13 Jun 2005)

To be honest, this plugin was intended as a proof of concept - I solved what I thought was the hardest problem and I was hoping that others would come along and mould the plugin to their needs. Feel free to sketch out your ideas and indeed to modify the plugin!

-- MartinCleaver - 13 Jun 2005

I've attached an early beta that adds support for .XLS files. Thanks to SamHasler for the code.

This requires CPAN:Spreadsheet::ParseExcel, CPAN:Spreadsheet::ParseExcelSimple; in turn they require OLE::Storage_Lite

Lightly tested on a Redhat server with an XP client.

-- MartinCleaver - 18 Jul 2005

checked .zip into CVS

-- WillNorris - 19 Jul 2005

This Excel publishing is now waiting for resolution of a ContentAccessSyntax through which the functionality can be exposed.

-- MartinCleaver - 19 Jul 2005

http://raw.cs.berkeley.edu/OfficePerl/ could be useful

-- MartinCleaver - 26 Jul 2005

As might http://www.oooforum.org/forum/viewtopic.phtml?p=45542&highlight=

-- MartinCleaver - 26 Jul 2005

I got this error after the converted doc2html at my page. Please help, see below three lines:


Document created with wvWare/wvWare version 1.0.3


I coudn't find a way to remove this message on the converted html file. Maybe MartinCleaver can advice me on this. Thanks in advance.

-- DonChai - 18 Aug 2005

Funny, page ran from Firefox seems alright, but not at MSIE. Getting confused why MSIE behalf differently from Firefox. ???

-- DonChai - 18 Aug 2005

Don, Martin is on holiday at the moment. I have read the code of the plugin, though, and I suspect your error is coming from the program that does the conversion (wvWare), and not the plugin.

-- CrawfordCurrie - 18 Aug 2005

Hi Crawford, thanks for your advice. I have checked and perform the manual translated at shell prompt, here are the code embedded after the translation. Please see below:

*Start of code:

<a href="http://wvware.sourceforge.net/"><img
src="wvSmall.gif" height=31 width=47
align=left border=0 alt="wvWare"></a>
<a href="http://validator.w3.org/check/referer"><img
src="vh40.gif" height=31 width=88
align=right border=0 alt="Valid HTML 4.0!"></a>
Document created with <a href="http://wvware.sourceforge.net/">wvWare/wvWare version 1.0.3</a><br>
*End of code:

*quoted by me.

Unfortunately, after the plugin does the translation and the page shown three lines of statement as mentioned at earlier comment post.

Could it be the TWiki script cause the interpretation error or etc? By the way, my TWiki specifications are listed below for your reference.

1. TWiki Cairo Production Release September 2004 2. Fedora Core 3 3. wvWare 1.0.3

Another possibility can it be MSIE not able to translate the mentioned codes? Where else Firefox is able to translate it?

-- DonChai - 19 Aug 2005

<a href="http://wvware.sourceforge.net/"><img
src="wvSmall.gif" height=31 width=47
align=left border=0 alt="wvWare"></a>
<a href="http://validator.w3.org/check/referer"><img
src="vh40.gif" height=31 width=88
align=right border=0 alt="Valid HTML 4.0!"></a>
Document created with <a href="http://wvware.sourceforge.net/">wvWare/wvWare version 1.0.3</a><br>
The codes were invisible because it was translated, and above was the original codes without quotes.

-- DonChai - 19 Aug 2005

<a href="http://wvware.sourceforge.net/"><img
src="wvSmall.gif" height=31 width=47
align=left border=0 alt="wvWare"></a>
<a href="http://validator.w3.org/check/referer"><img
src="vh40.gif" height=31 width=88
align=right border=0 alt="Valid HTML 4.0!"></a>
Document created with <a href="http://wvware.sourceforge.net/">wvWare/wvWare version 1.0.3</a><br>
-- DonChai - 19 Aug 2005

Does this work for drawingsl, e.g. drawings in a Word document or in a PowerPoint slideset or...

-- AndyGlew - 18 Mar 2006

After upgrading our ancient TWiki to v4.0.4 hotfix2 and installing MsOfficeAttachmentsAsHTMLPlugin, I noticed that it was giving the same error as the "TWiki 4.0.1 Upgrade Issues" note mentioned in BugzillaLinkPluginDev. I was able to fix it by changing all references of TWiki::Prefs::getPreferencesFlag to TWiki::Func::getPreferencesFlag

-- MichaelProto - 10 Aug 2006

I think you mean to say change TWiki::Prefs::getPreferencesValue to TWiki::Func::getPreferencesValue in MsOfficeAttachmentsAsHTMLPlugin.pm

-- ChrisPurves - 30 Aug 2006

Has anyone updated this plugin for v4?

-- MiloValenzuela - 27 Nov 2006

If someone is willing to pay for this work to be done I will update it for Dakar.

-- MartinCleaver - 27 Nov 2006

I managed to get this thing to work with Dakar. It took some serious hacking, since I've never written a plugin for TWiki before. It doesn't have any of the most recent changes that Martin made, but its working beautifully on my 4.1.x install. If anyone is interested, I'll upload my modified perl mod.

-- RossKramer - 22 Jun 2007

Of course we're interested ! smile

-- KeithHelfrich - 26 Jun 2007

I've uploaded my modified version. Feel free to have at it. As always, if anyone has any improvements, go for it. smile

-- RossKramer - 26 Jun 2007

I have tried the 26 Jun 2007 version. It works very well. I have found one problem with the converted output file. Images in the Word document are correctly stripped and saved in the pub directory; however, when the output is displayed to in TWiki the images are not loaded. I believe this is because the file is being looked for relative to the TWiki topic instead of relative to the doc.txt file which is in the pub directory. I couldn't find any way to get wvHtml to prepend the src location in order to fix this problem. Perhaps the resulting file would require a final search and replace to fix up the link.

-- ChrisPurves - 29 Jun 2007

If anyone is interested in having this plugin work with MailInContrib, see MailInContribWithMSOfficeAttachment.

-- ChrisPurves - 11 Sep 2007

I have embedded images working. The original problem is that wvhtml assumes that the produced html file will be viewed directly and not included in another document, so the path is not correct. I fixed this by changing the path to the image in the html file after it is written.

In MsOfficeAttachmentsAsHTMLPlugin.pm, I added the following to the end of sub convert

# This will go through the newly created html file and search and
# replace the graphics directories to point to the correct path

    open(HTML, "<$attachdir/$convertedAttachmentFile");
    open(TEMP, ">/tmp/twiki_attach_replace");
      $_ =~ s/$attachmentName[0-9]+/..\/pub\/$web\/$topic\/$&/g;
      print TEMP "$_";
    open(HTML, ">$attachdir/$convertedAttachmentFile");
    open(TEMP, "</tmp/twiki_attach_replace");
      print HTML "$_";
    writeDebug("Search and replaced image attachment paths.");

I am not a perl programmer, so I'm sure the above could be improved upon.

-- ChrisPurves - 13 Sep 2007

Topic attachments
I Attachment History Action Size Date Who Comment
Perl source code filepm MsOfficeAttachmentsAsHTMLPlugin.pm r1 manage 7.6 K 2005-07-18 - 17:16 MartinCleaver very beta
NEWnew MsOfficeAttachmentsAsHTMLPlugin.pm.new r1 manage 6.5 K 2007-06-26 - 20:35 RossKramer Updated version of this plugin which seems to run happier in 4.1.x. Still kinda beta...
Edit | Attach | Watch | Print version | History: r48 < r47 < r46 < r45 < r44 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r48 - 2007-09-13 - ChrisPurves
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.