This project has moved. For the latest updates, please go here.

Docx replace

Aug 2, 2012 at 12:38 PM

Hi all,

I'm successfully using Docx as part of a document generation system. I use [placeholder] text and replace it programatically to generate documents. One issue I've noticed is that the search and replace operation is quite slow, my document has up to 130 replacement fields and it takes over a minute to return the new document. I've also noticed that it maxes out one core for the duration, so it seems to be cpu-bound.

I'm just wondering if there are any performance issues in this area, and also if its worth  considering a 'document merge' feature where rather than calling replace(x,y) in a loop you pass a NameValueCollection to the document and it merges internally. The benefits of the latter approach is that it might be much quicker to scan each internal paragraph for all keys at once rather than traversing the complete document for each loop.

 

What do you guys think?

Jonathan

Aug 2, 2012 at 11:47 PM
Hi Jonathan,

Cathal and I swapped a bunch of emails some time ago about some performance issues I was having. Turns out most of my issue was that, when merging documents, I was adding a page break to the 'master' document and then inserting another doc. It's actually much faster to add the page break to the document you're about to insert, and then add that to the master.

Anyhoo, Cathal also suggested search and replace my not be the best approach for me either and pointed me at this post - http://cathalscorner.blogspot.co.nz/2009/02/docx-net-library-for-manipulating-word.html. You may want to check it out.

Hope that helps,
Alan

On 3 August 2012 00:38, jonathanmcnamee <notifications@codeplex.com> wrote:

From: jonathanmcnamee

Hi all,

I'm successfully using Docx as part of a document generation system. I use [placeholder] text and replace it programatically to generate documents. One issue I've noticed is that the search and replace operation is quite slow, my document has up to 130 replacement fields and it takes over a minute to return the new document. I've also noticed that it maxes out one core for the duration, so it seems to be cpu-bound.

I'm just wondering if there are any performance issues in this area, and also if its worth considering a 'document merge' feature where rather than calling replace(x,y) in a loop you pass a NameValueCollection to the document and it merges internally. The benefits of the latter approach is that it might be much quicker to scan each internal paragraph for all keys at once rather than traversing the complete document for each loop.

What do you guys think?

Jonathan

Read the full discussion online.

To add a post to this discussion, reply to this email (DocX@discussions.codeplex.com)

To start a new discussion for this project, email DocX@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com