We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Replace a plain text with a template doc.

I've an evaluation version of DocIO, I am trying to accomplish some requirements, so far most of then are fulfilled, however I'd like to expose the following questions:

Is it possible find a plainText for instance:
PlaceHolder99 and replace with a existing template.

I saw a example of your, but this example does firs a find a in the source template, collects the text and then replaces with this selected text. What I am looking for is to to replace this plain text by this source template.

Sample:

docMaster.Open(Path.Combine(dataPath, "TemplateMaster.doc"), FormatType.Doc);
docSource1.Open(Path.Combine(dataPath, "TemplateSource1.doc"), FormatType.Doc);
docMaster.Replace(new Regex("PlaceHolder1"), <>);


Thanks a lot for your help.
Regards
Joshua




3 Replies

FS Fathima Shalini P Syncfusion Team December 11, 2007 10:39 AM UTC

Hi Joshua,

Thanks for your interest in Syncfusion Products.

Please do find the sample in the following link.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70371/main.htm

This sample finds the text in source template and replaces with the text in the sample source template. If I have misunderstood your requirement could you please explain me in detail, so that I can work in depth and try to send a better solution.

Please let me know if any questions regarding.

Regards,
Fathima.



JM Josue Medrano December 11, 2007 03:21 PM UTC

Hi Fathima,
What I need to accomplish is Insert a document(Template2) into another document(Template1) at a specific place.
I don't want to search any specific text in document in (Template2).

For instance:
I have two templates DOC1.doc and DOC2.doc.
I have plain Text in DOC1 named " [%Placeholder1%] " which I want to replace it with the hole content of DOC2.doc

Is it possible to do this?.

I appreciate very much your help.

Best Regards
Joshua



>Hi Joshua,

Thanks for your interest in Syncfusion Products.

Please do find the sample in the following link.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70371/main.htm

This sample finds the text in source template and replaces with the text in the sample source template. If I have misunderstood your requirement could you please explain me in detail, so that I can work in depth and try to send a better solution.

Please let me know if any questions regarding.

Regards,
Fathima.





BP Bhuvaneswari P Syncfusion Team December 12, 2007 10:59 AM UTC

Hi Joshua,

Thanks for the update.

Is it possible to replace a placeholder with the hole content of another document.in other words marge a word ducument into other in a desired place.?

Yes, it is possible to find the particular text in source document and replace it with the content of another whole document using TextBodyPart. You need to select the whole document using the tectBodySelection, then copy the selected text into the TextBodyPart.

The following code snippet illustrates this..

//Select text and image
TextBodyPart replacePart = new TextBodyPart(replaceDoc);

//Select the whole document
TextBodySelection textSel = new TextBodySelection(replaceDoc.LastSection.Body, 0, replaceDoc.LastSection.Paragraphs.Count,0,1);

//Copy the selected area into the TextBodyPart
replacePart.Copy(textSel);

//Replace Text with image and text.
doc.Replace("INSERT PARAGRAPH ITEMS", replacePart, false, true);

Please downlaod the sample from the below link which demonstrate the above concept
http://websamples.syncfusion.com/samples/DocIO.Windows/F70419/main.htm

Please take a look into the sample and let me know if this helps you.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon