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

Character Style Types

Does DocIO support Character Style types? I need to be able to apply a style to a text range within a paragraph, that is, have several text ranges in one paragraph with different character styles. Using character format to achieve this is not sufficient because this is just formatted text not text using a given style. Is it possible to do this with DocIO? I've been looking through the class hierarchy and I can't seem to find a way to do it. WTextRange only has ApplyCharacterFormat(), not ApplyStyle() like WParagraph.

8 Replies

RA Rajendran Syncfusion Team January 18, 2010 03:11 PM UTC

Hi Chris,

Thank you for your interest in Syncfusion Products.

Currently we are using character format for formatting the character. In future we will enhance character style to support just like styles in paragraph. Regarding your query Please try our code snippet to apply a style to a text range within a paragraph.

http:// files.syncfusion.com/samples/DocIO.Web/CharacterStyles.zip

Please let us know if you have any questions.

Regards,
Rajendran


RA Rajendran Syncfusion Team January 18, 2010 03:24 PM UTC

Hi Chris,

Thank you for your interest in Syncfusion Products.

Currently we are using character format for formatting the character. In future we will enhance character style to support just like styles in paragraph. Regarding your query Please try our code snippet to apply a style to a text range within a paragraph.

http://files.syncfusion.com/samples/DocIO.Web/CharacterStyles.zip

Please let us know if you have any questions.

Regards,
Rajendran


CL Chris Lindsay January 19, 2010 05:49 AM UTC

Yeah I had looked at that sample before starting this post. For what I need to do, applying a character format is no good. I must be able to apply a style to a text range within the paragraph.

The problem originates from the fact that when I import content from one document to another where the two documents have a style with the same name and same character format DocIO introduces a new style, this is not how Word behaves. I am trying to find a work-around for this problem, but I'm restricted by this DocIO limitation.

Is there any other way by which I can apply a style to a text range rather than the paragraph?



RA Rajendran Syncfusion Team January 19, 2010 11:38 AM UTC

Hi Chris,

Currently we are supporting character format for text range. In future release we will enhance it to character styles. Kindly try the following code snippet to apply formatting to a text range.

// Apply formatting for text range
textRange = paragraph.AppendText("We are a leading provider of software components and tools for the Microsoft .NET platform.");
textRange.ApplyCharacterFormat(style.CharacterFormat);

For importing content from one document to another without loosing the style use the following code snippet.

WordDocument document = new WordDocument("Sample1.doc", FormatType.Doc);
WordDocument doc = new WordDocument("Sample.doc", FormatType.Doc);

/* Importing content from one document to another.Here boolean value - true denotes importing content along with styles from one document to another.*/

doc.ImportContent(document, true);

Please do find the sample from the below location which illustrates the same and provide more information if we misunderstood your requirements.

http://files.syncfusion.com/samples/DocIO.Web/ImportCharacterStyles.zip

please let us know if you have any questions.

Regards,
Rajendran



CL Chris Lindsay January 20, 2010 12:55 AM UTC

Nice one. I actually need to use ImportContent(documentToImport, false) since I don't want to bring the styles from the import document, instead I want the styles in the target document to be applied. Where the two documents contain the same styles, importing the content with the import styles flag set to false causes the imported content to use the styles of the main document. Don't know if this true for all cases, but it seems to solve my problem.

Thanks.


RA Rajendran Syncfusion Team January 20, 2010 04:47 AM UTC

Hi Chris,

We are glad that your problem has been solved.

Please let us know if you have any questions.

Regards,
Rajendran


MA Muhammad Ali Chughtai February 14, 2010 01:52 PM UTC

Hi can i have a good example of creating a document using docio like i have seen it on

http://www.scriptingjournal.com/2010/01/create-a-document-using-syncfusion-docio/


RA Rajendran Syncfusion Team February 16, 2010 02:58 PM UTC

Hi Muhammad,

Thank you for your interest in Syncfusion Products.

Please do find the sample from the below location and provide more information if we misunderstood your requirements.

http://help.syncfusion.com/samples/DocIO.Windows/SampleDocEx.zip

Please let us know if you have any other questions.

Regards
Rajendran

Loader.
Live Chat Icon For mobile
Up arrow icon