We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Delete style

Hi,

I need to remove perticular style from the document, is there any method to delete/remove style in Styles class?

Thanks,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Unfortunately, Aspose.Words does not support removing particular styles from documents. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.

Best regards,

Hi Andrey,

Thanks for your response, but i need some help from your side as a workarround if the styles are not deleting.
I am using NodeImporter class to import some of the perticular nodes into another doc like,

NodeImporter importer = new NodeImporter(mainSec, MainDocument, ImportFormatMode.KeepSourceFormatting);

the enumerator ImportFormatMode.KeepSourceFormatting is mandatory for me to import perticular node, but in this process, if the source doc having Heading 1 style, after using this ImportFormatMode.KeepSourceFormatting, Heading 1 is copied to destination document as Heading 1_0, So i need to remove this style, is there any way to work arround on this, like to permanently remove Heading 1_0 style or it should not applied to document content (actually the heading styles are showing Heading 1_0 insted of Heading 1)
Could you please help me out on this to overcome…

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think, in your case, you can try using ImportFormatMode.UseDestinationStyles. In this case, only styles, which do not exist in the destination document, will be copied.

Hope this helps.

Best regards,

Hi Andrey,

Thanks for your response, why i am using ImportFormatMode.KeepSourceFormatting insted of ImportFormatMode.UseDestinationStyles is, in my source document the list number of Heading style was not starting with 1, it might changed depends upon our requirements, some times it was 4 or 6 or 10… PFA for my source document.

So i need to copy/import that heading style into another main document with same list number, so this is possible with
ImportFormatMode.KeepSourceFormatting, but the problem is after importing that node with KeepSourceFormatting list number is coming fine, but one more Heading 1_0 style was creating in main document and that Heading 1_0 was applying to heading paragraph insted of Heading 1.

So is there any other ways to move/copy/import that node into another document with same list number without copying dummy Heading 1_0 style??

So my main document looks like:
4. Roles and Responsibilities
*** some text here ***
6. some other heading
** some text here **

Could you please suggest me, how to do this without creating Heading 1_0 in main document.

Thanks,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I used the following code for testing. And numbers in the source document are preserved.

Document dst = new Document(@"Test001\Destination.doc");

Document src = new Document(@"Test001\Source.doc");

dst.AppendDocument(src, ImportFormatMode.UseDestinationStyles);

dst.Save(@"Test001\out.doc");

Could you please also attach your destination document and provide me your code? I will check the issue and provide you more information.

Best regards.

Hi Alexey,

Thanks for your response, please find my attachments how source and destination docs and what i need in final/output document.

I used the above code, but ImportFormatMode.UseDestinationStyles was not copying correct list style number (showing 3 in my destDoc, actually it should be 7, so i used ImportFormatMode.KeepSourceFormatting, here list style number was copyied properly, but the problem was one more extra style Heading 1_0/Heading 2_0 were created, i need to delete those styles or i need to apply Heading 1 insted of Heading 1_0)

Thanks,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You can try using the following code as a workaround:

// Open source and destination documents.

Document dst = new Document(@"Test001\Dest.doc");

Document src = new Document(@"Test001\src.doc");

// Get list, which belongs to heading styles.

List lst = src.Styles[StyleIdentifier.Heading1].ListFormat.List;

if (lst != null)

{

// Set the list to each paragraph of headign style.

NodeCollection paragraphs = src.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

// reset list

if (paragraph.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1 ||

paragraph.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading2 ||

paragraph.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading3)

paragraph.ListFormat.List = lst;

}

}

dst.AppendDocument(src, ImportFormatMode.UseDestinationStyles);

dst.Save(@"Test001\out.doc");

This code just sets list directly to paragraphs, and not through the style.

Hope this helps.

Best regards.

The issues you have found earlier (filed as WORDSNET-2304) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(42)