My apologies in advance if this cannot be done using Telerik Document Processing and I'm wasting everyone's time. I'll try and explain my situation the best I can.
We have large number of word documents related to a process which need to be converted to online forms. That's the easy part. The business wants the reporting of these forms exactly in the same format as in the original word documents. So we are hoping to use the word documents as templates (not necessarily .DOTX).
Since the format of word documents often change The idea is to
- Have one base document of each format kept on the server.
- This base doc will have place-holders for the data to be filled in by asp.net (C#) for e.g. Employee Name: <<NAME>>.
- When a report is to be generated, the relevant data is pulled from the SQL database and filled in the placeholders of the document. So in the above example <<NAME>> will be replaced by real name of the employee from database.
- There will be some Base64 Images which will come from database and to be placed in the document e.g. signatures, profile pictures.
- Once the document is completely filled, it is converted to PDF and downloaded to user's browser.
- Whenever the format of a word document changes, it is replaced on the server and the asp.net fills this new format.
Since we are in design phase of this I'm open to adapt to any suggestions. Any pointers/demo/advice on approach is welcome.
Thanks in Advance.
10 Answers, 1 is accepted
You can achieve the desired scenario using the WordsProcessing library. The Mail Merge feature will help you implement the placeholders in the template DOCX document. You can generate the template using the API of WordsProcessing and then export it via DocxFormatProvider. When you have the data from the customer, you will need to perform the mail merge, then export the document to PDF with the PdfFormatProvider class.
There are several from our online examples that will help you in getting a better understanding of the features and in implementing the scenario. You will find them at http://demos.telerik.com/aspnet-ajax/wordsprocessing/.
Hope this is helpful.
Telerik by Progress
Thank you for your reply. I was suspecting that Mail Merge should be the solution for this.
I actually have been previously to the WordsProcessing Mail Merge example here that you've mentioned here, however it is not working. When you click the Mail Merge button, I get page not found error. So got confused. Might be something for your guys to fix.
I will get the developers have a look at WordsProcessing and Mail Merge. Will get back to you in case they get stuck somewhere.
Thanks again for the pointers.
Works perfectly now
we have taken your suggestion and moved ahead with Mail Merge for for generating our reports. However have hit a roadblock. We need to insert images in some merge fields (user signatures etc.). The images are stored as Base64 in an SQL database. could you please provide some suggestions or point us to examples which demonstrate how to insert an image from database onto a merge field of a document.
Thanks in advance
Hi Tanya / Any other admin,
Could you please provide some help on the issue that we are facing (add image from DB to Mail Merge) its proving to be a roadblock for us.
You can find the placeholder and replace it with the image using code similar to the following one:
The ImageSource constructor overloads allow you pass a byte or a stream containing the image data, so you will need to convert the Base64 string.
We have also logged a feature request to implement similar functionality in RadWordsProcessing: INCLUDEPICTURE field. You can vote for its implementation and track its status through the public item in our feedback portal.
Telerik by Progress
The INCLUDEPICTURE field is still not supported in RadWordsProcessing and you can vote for the implementation of the feature as well as subscribe to track its status using the related public item on our portal. In this item, you will find a description of how you could replace keywords with images using the API of WordsProcessing, similar to the one shown in my previous post.
Hope this helps.
I had impression, that it is implemented. Anyway, your example is working fine.