Processing of ColdFusion COM object objects for MS Word 2000 dies after 100 seconds

I am using ColdFusion 7 on a Windows 2003 server to talk about installing Microsoft Word 2000 by default using COM objects. The goal is to generate a document with some tables in it.

What I can do. The processor accumulates up to 100% all the time, but my code is functioning, and if it is short, it works. The problem I am facing is when the code used to create the Word document is about 25 kb + (a script generates a lot of repeating code).

After the server spends 1 minute 40 seconds trying to create a document:

  • CPU load drops to 0 (CPU was split between jrun.exe for ColdFusion and winword.exe for Word 2000).
  • winword.exe remains in memory.
  • The ColdFusion timeout is long, so the client browser considers that the page is still processing ...
  • If I kill the winword.exe process, ColdFusion immediately returns an error to the client.

Thus, these longer pages never end. I have tried many options.

  • ColdFusion 8 does not work.
  • Using the updated JVM for ColdFusion 7/8 does not work.
  • The content of the code that I run does not matter. I do a lot of beautiful coloring, but millions of lines of "Hello world" are also dying.
  • Testing Word 2007, surprisingly, really works. Formatting is a bit inconvenient, since it applies by default to Calibri and other new fonts, but the server will wait until, say, 7 minutes before it finishes. And then reboot the server, try the same code, and Word 2007 insists that it does not understand any command that I am sending. I performed a trial activation, I even started using Word 2007 using Remote Desktop after rebooting. After the first restart, Word becomes completely catatonic.

What I have not tried:

  • Word 2003

My network searches were fruitless after “here, how to connect to the Word API” on the ColdFusion land and “here, how to put the number of pages in the footer” on ASP.NET ground. Nobody using Adobe seems to be trying to do this, and nobody using Microsoft stuff has a problem. And so I rush to your shores, bleeding and exhausted, looking for some idea of ​​this problem with an insane waiting time.

Here's what the ColdFusion code snippet looks like:

<cfset clientMatterCellStart = myDoc.Tables.Item(1).Cell(2,1)> <cfset clientMatterCellEnd = myDoc.Tables.Item(1).Cell(2,7)> <cfset clientMatterCellStart.Merge(clientMatterCellEnd)> <cfset clientMatterCellStart.Range.Font.Bold = true> <cfset clientMatterCellStart.Range.Font.Name = "Times New Roman"> <cfset clientMatterCellStart.Range.Font.Size = 14> <cfset clientMatterCellStart.Range.ParagraphFormat.Alignment = 1><!--- Centered ---> <cfset clientMatterCellStart.Range.Text = "#MySubjects.subject_name[q]#"> <cfset clientMatterCellStart.Shading.BackgroundPatternColor = 13421772><!--- Grey 20% ---> 
+4
source share
7 answers

Ok, answer number 2. Since .Net developers say this works, you may be able to create a document using an external vb.net script and pass any special requirements through the configuration file and / or command line arguments, Alternatively, if you prefer real language, you can do it in python using the win32com module.

In short, your problem might be that Coldfusion has a crappy COM implementation.

+3
source

I had a need to create MS Word documents before that and a lot of research in which this is the best way to do this. In the end, I found out that using MS Word as a COM object is really a very bad idea, mainly because of the performance issues you mentioned, and also because of the security issues that it brings. This is just a bad idea and will definitely not scale for multiple users.

However, I came up with two other acceptable solutions. It was quite a while ago and I no longer have the code with me, but I will tell you that I can remember as much as possible.

  • I saved the Word document as an xml text document, opened it in a text editor, split it, and used ColdFusion to automatically create what I needed. This worked well and there were no performance issues, but splitting the xml and figuring out how to do what I needed was tedious and took some time.

  • I just did the regular html, creating a report to look beautiful like a web page, and then added the cfheader and cfcontent tags to tell the browser that it was a text document. This option worked, but I think that I may have warnings that the attachment is not formatted correctly as a text document, do you still want to open it? The discovery in MS Word turned out to be beautiful, and users could save it on the desktop as a doc file.

Hope this helps.

EDIT: Sorry, my code snippet is not showing correctly, here it is ...

 <cfheader name="content-disposition" value="attachment; filename=report.doc" /> <cfcontent type="application/msword" /> 
+2
source

Try a different browser? I had my share of problems with IE disconnecting long-term connections ahead of schedule (regardless of setting the CF request time). It seems that long requests mean that the server is broken, so it is interrupted (even when the reason for the delay is due to the fact that it is still downloading the file).

0
source

I do not assume that converting HTML to PDF instead of Word is an option?

0
source

You are probably right - you are in a small group of people trying to do such things.

If you have the opportunity to write a .Net class or web service, this may be the way, because it looks like the ColdFusion COM implementation is poor.

Think about your process and try reorganizing the part of your code that creates the document, then write it to .Net and use this class / service from ColdFusion.

0
source

I totally agree with everyone here, saying that COM is a bad idea.

Why should I have good results that convert very long hundreds of pages - and quite complex documents in Word, using HTML files created by Coldfusion, with CSS style sheets.

Just execute them in Word with

 <cfcontent type="application/msword" file="#filename#" deletefile="Yes" /> 
0
source

I had my share of problems with ColdFusion and COM (we used it to consume word and PPT and convert to HTML). I think you better write a .aspx page or .NET web service and pass the necessary information. If you plan to do more manipulations with MS Office documents, you should pay for the solution: http://www.aspose.com/categories/file-format-components/aspose.words-for-.net-and-java/default. aspx

We used them for PPT files and were very pleased.

0
source

Source: https://habr.com/ru/post/1286011/


All Articles