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

line break and bold

Hi

I am using the find and replace method of the docIO component. Works well. However, I need to be able to make some code bold and insert a line break..

Here's the code so far (dr is a datareader):

varDetails = varDetails & "Bedroom 5:" & dr("bedroom5") & ""
....
...
document.Replace("<
>", varDetails, True, True)

Any ideas?

Thanks for your help
Peter



8 Replies

BP Bhuvaneswari P Syncfusion Team July 21, 2008 01:31 PM UTC

Hi Peter,

Thank you for your interest in Syncfusion products.
Yes, it is possible to find and replace the text with for formatted text. We can find the string and replace the text with textbodypart. Please refer the below code snippet to do so:

[C#]

TextBodyPart part = new TextBodyPart(doc);
IWParagraph par = new WParagraph(doc);
//Bedroom 5:" & dr("bedroom5") & ""
par.AppendText(" Syncfusion").CharacterFormat.Bold =true;
par.AppendText("Syncfusion");
part.BodyItems.Add(par);
//Replace Text with image and text.
doc.Replace("INSERT PARAGRAPH ITEMS", part, false, true);


Please take a look into the sample bowser sample from the below location:
\\Syncfusion\EssentialStudio\x.x.x.x\Windows\DocIO.Windows\Samples\2.0\Editing\ReplaceWithDocumentElements\CS

Please let me know if you have any other questions.

Best Regards,
Bhuvana



PC peter crymble July 21, 2008 04:49 PM UTC

thanks - having problems - would you mind providing that snippet in VB?

Thanks



PC peter crymble July 21, 2008 05:24 PM UTC

Sorry - got that work. Thanks.

However, the still appears in the document i.e. it does not take a new line...

Thanks



BP Bhuvaneswari P Syncfusion Team July 22, 2008 12:04 PM UTC

Hi Peter,

Thanks for the update.

I am afraid that I am not able to reproduce the issue. In our end its working fine.

Please provide the below information to reproduce the issue:
1. Office version
2. Essential Studio version
3. OS

You can you the line break also to insert new line. Please refer the below code:

par.AppendText(" Syncfusion").CharacterFormat.Bold = True
par.AppendText("Syncfusion")
par.AppendBreak(BreakType.LineBreak)
par.AppendBreak(BreakType.LineBreak)
par.AppendText(" After line break").CharacterFormat.Bold = True
part.BodyItems.Add(par)
'Replace Text with image and text.
doc.Replace("INSERT PARAGRAPH ITEMS", part, False, True)


Please try this and let us know if this helps you.

Best Regards,
Bhuvana



PC peter crymble July 24, 2008 10:36 AM UTC

Hi

Thanks - the appendbreak code works great. One last question then I'm done!!!

I add a paragraph style. It adds to the word doc but doesnt apply it. Any ideas?

Dim style As IWParagraphStyle = CType(document.AddParagraphStyle("Normal"), IWParagraphStyle)
style = CType(document.AddParagraphStyle("move_detail"), IWParagraphStyle)
style.CharacterFormat.Bold = False
style.CharacterFormat.FontName = "Arial"
style.CharacterFormat.FontSize = 10


par.ApplyStyle(style.Name)
par.AppendText("Lounge:").CharacterFormat.Bold = True
par.AppendText(dr("lounge"))
par.AppendBreak(BreakType.LineBreak)
etc. etc....



BP Bhuvaneswari P Syncfusion Team July 25, 2008 12:39 PM UTC

Hi Crymble,

Thanks for the update.

I am afraid that I am not able to reproduce the issue. I can able to apply the styles to the paragraphs without any issues.

Here is the test sample for your reference:
http://websamples.syncfusion.com/samples/DocIO.Windows/F75293/main.htm

Please have a look into the sample and send us the modify the sample to reproduce the issue, this would be very help full to reproduce the issue in our end and investigate more on this issue. Please send us your system configuration also.

Best Regards,
Bhuvana



PC peter crymble July 29, 2008 10:31 AM UTC

Hi
Fixed! Just for anyone else having this issue. The text I was replacing had the word 'normal' style applied to it. I just took the style out of the template, and it works.

thanks
P

>Hi Crymble,

Thanks for the update.

I am afraid that I am not able to reproduce the issue. I can able to apply the styles to the paragraphs without any issues.

Here is the test sample for your reference:
http://websamples.syncfusion.com/samples/DocIO.Windows/F75293/main.htm

Please have a look into the sample and send us the modify the sample to reproduce the issue, this would be very help full to reproduce the issue in our end and investigate more on this issue. Please send us your system configuration also.

Best Regards,
Bhuvana





BP Bhuvaneswari P Syncfusion Team July 29, 2008 10:40 AM UTC

Hi Peter,

Thanks for the update.

Glad to know that your issue has been fixed.

Please let me know if you have any questions.

Best Regards,
Bhuvana


Loader.
Live Chat Icon For mobile
Up arrow icon