We are getting the error “Too many styles in
the document”. Looking through the forum this issue came up back in 2011 but I did not see any resolution. Is there a work around or fix for this issue? We just purchased your product as it passed our testing phase without seeing this error. This is a major issue for our clients and we need it fixed.
Hi Steven,
Attached is a zip file with the docx templates. Out letter processor generates anywhere from 100’s to 1000’s of letters using these templates.
We have found a work around for now to get the system to complete.Its a bit of a hack and would be better if we had direct control over removing duplicate styles or having Aspose detect duplicate styles and not adding to the Styles list if it is already there. Basically we noticed when trying to stich more than 2000 letters together the style list will start pitching fits. By the time we get through 1500 letters we are almost sure that all the styles we will ever need are in the list so we change the mode and carry on. Our other solution was to use Microsofts API and affect the styles list directly. To get through this quick so our customers are not impacted any more we implimented the following hack / work around
intcnt = 0;
ImportFormatMode mode = ImportFormatMode.KeepSourceFormatting;
</p><p>foreach (DOM.Classes.Letter letter in LettersToGroup)</p><p>
{</p><p> <br> if (cnt++ > 1500)<br> mode = ImportFormatMode.UseDestinationStyles;<br><br> if (letter.OutputPath == null || !System.IO.File.Exists(letter.OutputPath))<br> throw new ArgumentNullException(string.Format("letter.OutputPath is null or file does not exist for {0} letter with path {1}", letter.TemplateName, letter.PdfPath));<br><br> if (letter.MarkedForEmail)<br> if (emailFile == null)<br> emailFile = new Aspose.Words.Document(letter.OutputPath + ".docx");<br> else<br> emailFile.AppendDocument(new Aspose.Words.Document(letter.OutputPath + ".docx"), mode);<br> else<br> if (file == null)<br> file = new Aspose.Words.Document(letter.OutputPath + ".docx");<br> else<br> file.AppendDocument(new Aspose.Words.Document(letter.OutputPath + ".docx"), mode);<br> }</p>
Hi Steven,
The issues you have found earlier (filed as WORDSNET-4173) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(14)
Starting from Aspose.Words 20.5, we added new feature to remove duplicate styles from the document using CleanupOptions.DuplicateStyle property. Following code snippet shows how to use this property.
Document doc = new Document(fileName);
CleanupOptions options = new CleanupOptions();
options.DuplicateStyle = true;
doc.Cleanup(options);
doc.Save(outFileName);