c# Office Interop Slow When Looping through each word in a large document

I am developing a course that builds a Word document from square one. All went definitely effectively, but I can not surpass a particular bug. The concern I experience is that I have a paragraph as well as I would like to establish the Room Before to a specific value, yet when I develop the document the paragraph accompanies all my setups other than the ideal space prior to.

Prefered platform is actually ASP.NET along with C#.

There’re a record list with thousands of data things (expect each thing is actually a client), and a predefined word document as design template, the criteria is actually – for each and every information product, fill equivalent data right into template fields, and produce a readonly PDF documents as result.

I have the following code section which loopholes by means of each word in a Word document, finds series (paragraphes) which are actually bolded and shops them in a list, MasterSentences.

It’s challenging to give you a valuable solution without understanding exactly what it is you need to have to carry out. Can you describe a lot more properly what you take into consideration a “Paragraph” to become? Take note that Word does have a Paragraphes collection, which may be actually more effective than the Phrases selection. The suggestion of making use of Range.Find will probably be actually most effective, if your phrases give themselves to Word’s integrated search functionalities – but our experts can’t determine that without even more precise information. You can manage a Discover end result. There are actually great deals of examples of making use of Selection utilizing C#.

I discovered 2 answers:

Customer remedy: use Microsoft.Office.Interop.Word (Office2007+ plugin or even Office2012) to check out data, convert to pdf, and so on. But this method working on hosting server side might be unsafe.

Improvement words document in to a PDF application, and make use of iTextSharp to load the document fields. But develop the PDF form along with correct style (font, format, and so on) is actually a complicated work, and it requires certain tool as well as brand-new skill-set when system user wishes to incorporate brand-new layout (unless the PDF form is actually constantly generated through programmer).

Web server option:
Produce PDF form, and use iTextSharp to load the form fields. The downside has actually been stated over.
Produce HTML template, and also switch out industry placeholders, and use iTextSharp+XMLWorker to convert HTML to PDF. The challenge is create the HTML theme manually and also improve the PDF result.
MS SharePoint Office Computerization Company is a web server option based on MS Office, probably this method will certainly be much easier, but it requires permit and SharePoint server expense.

For the 2nd choice you can make use of iTextsharp or even Aspose which supports the placeholder replacement and age PDF, it backs creating reports based upon design templates of MSWord and also Openoffice which may be usefull for user who carry out not wish to buy MSWord just to generate a design template.

Yet another alternative would be actually to make use of Tx Text Control for ASP.NET. They have a mailmerge component that permits you to fill records right into a word layout. The joined document may quickly be actually saved as a pdf.

Include text placeholder in words report, as well as the course can go through word report, replace message, as well as exchange PDF. But I am actually unsure which elements should be actually utilized.

Leave a Reply

Your email address will not be published. Required fields are marked *