public void ExtractPlainTextTest() { const RtfParserListenerLogger parserLogger = null; //parserLogger = new RtfParserListenerLogger(); IRtfGroup rtfStructure = RtfParserTool.Parse(GetTestResource("RtfInterpreterTest_0.rtf"), parserLogger); Assert.IsNotNull(rtfStructure); const RtfInterpreterListenerLogger interpreterLogger = null; //interpreterLogger = new RtfInterpreterListenerLogger(); var rtfString = @"{\rtf1\sste16000\ansi\deflang1033\ftnbj\uc1\deff0 {\fonttbl{\f0 \fnil Verdana;}{\f1 \fnil \fcharset0 Verdana;}} {\colortbl;\red0\green0\blue0;} {\stylesheet{\f0\fs28 Normal;}{\cs1 Default Paragraph Font;}} {\*\revtbl{Unknown;}} \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery720\footery720\nogrowautofit\deftab720\formshade\fet4\aendnotes\aftnnrlc\pgbrdrhead\pgbrdrfoot \sectd\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\headery720\footery720\sbkpage\pgncont\pgndec \plain\plain\f0\fs24\plain\f0\fs24\plain\f1\fs28\lang1033\hich\f1\dbch\f1\loch\f1\cf2\fs28 test again and again and again }"; var rtfString2 = @"{\rtf1\sste16000\ansi\deflang1033\ftnbj\uc1\deff0 {\fonttbl{\f0 \f \fcharset0 Arial;}} {\colortbl ;\red255\green255\blue255 ;\red0\green0\blue0 ;\red0\green0\blue0 ;} {\stylesheet{\f0\fs24 Normal;}{\cs1 Default Paragraph Font;}} {\*\revtbl{Unknown;}} \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery720\footery720\htmautsp1\nogrowautofit\deftab720\formshade\fet4\aendnotes\aftnnrlc\pgbrdrhead\pgbrdrfoot \sectd\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\headery720\footery720\sbkpage\pgncont\pgndec \plain\plain\f0\fs24\ltrpar\ql\plain\f0\fs24\plain\f0\fs24\lang1033\hich\f0\dbch\f0\loch\f0\cf2\fs24\ltrch this is my cover changed in bulk\plain\f0\fs24\par and then in text\par }"; var rtfString3 = @"{\rtf1\sste16000\ansi\deflang1033\ftnbj\uc1\deff0 {\fonttbl{\f0 \fnil Arial;}{\f1 \fnil \fcharset0 Arial;}} {\colortbl ;\red0\green0\blue0 ;\red255\green255\blue255 ;\red0\green0\blue0 ;\red255\green0\blue0 ;\red0\green0\blue0 ;} {\stylesheet{\f0\fs24 Normal;}{\cs1 Default Paragraph Font;}} {\*\revtbl{Unknown;}} \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery720\footery720\nogrowautofit\deftab720\formshade\fet4\aendnotes\aftnnrlc\pgbrdrhead\pgbrdrfoot \sectd\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\headery720\footery720\sbkpage\pgncont\pgndec \plain\hich\f0\dbch\f0\loch\f0\cf1\fs24\pard\lang1033\hich\f1\dbch\f1\loch\f1 12:24 v3465 AP-APTN-1630: Turkey Syria Wednesday, 3 October 2012\par STORY:Turkey Syria- Shell fired from Syria kills three in Turkey LENGTH: 00:40\tab FIRST RUN: 1530 RESTRICTIONS: No Access Turkey/ROJ TV TYPE: Natsound SOURCE: Anadolu Agency STORY NUMBER: 861347\par DATELINE: Sanliurfa - 3 Oct 2012 LENGTH: 00:40\tab\par \par \par \cf4\b\protect [Duration: 07:06]\plain\f1\fs24 \par \par \par SHOTLIST:\par 1. Wide of smoke rising, policemen run for cover and surround wounded officer lying on ground 2. Wide of street, smoke seen rising from the distance 3. Tracking view of wounded person in a car which pulls away, policemen seen in background surrounding injured officer lying on the ground 4. Mid plainclothes officers leading crowd and media away from injured officer 5. Wide of street with smoke seen, people running along\par STORYLINE:\par A Turkish official said on Wednesday that a shell fired from Syria had landed on a house in neighbouring Turkey, killing at least three people, including a 6-year-old boy.\par Abdulhakim Ayhan, the mayor of the Turkish town of Akcakale which is along the Syrian border, told Turkey's state-owned Anadolu Agency that the boy and a woman were among the dead in Wednesday's shelling.\par Anadolu Agency reported angry townspeople marched to the mayor's office to protest against the deaths.\par Video from the Anadolu agency purportedly also showed at least one policeman was also injured in the incident.\par The village was also hit by a mortar shell on Friday, though no-one was injured on that occasion.\par The Turkish Foreign Minister Ahmet Davutoglu called an emergency meeting to discuss developments, after receiving information on the incident from Turkish Armed Forces.\par ===========================================================\par Clients are reminded: (i) to check the terms of their licence agreements for use of content outside news programming and that further advice and assistance can be obtained from the AP Archive on: Tel +44 (0) 20 7482 7482 Email: infoaparchive.com (ii) they should check with the applicable collecting society in their Territory regarding the clearance of any sound recording or performance included within the AP Television News service (iii) they have editorial responsibility for the use of all and any content included within the AP Television News service and for libel, privacy, compliance and third party rights applicable to their Territory.\par APTN\par \par \par \tab \par \tab (Copyright 2012 by The Associated Press. All Rights Reserved.)\par \tab AP-NY-10-03-12 1224EDT\par \par \fs18\par \ql\lang1033\hich\f0\dbch\f0\loch\f0\cf1\fs24\plain\f1\fs24\par }"; RtfTextConverter textConverter = new RtfTextConverter(); //RtfInterpreterTool.Interpret( rtfStructure, textConverter, interpreterLogger ); RtfInterpreterTool.Interpret(rtfString3, textConverter, interpreterLogger); string plainText = textConverter.PlainText; Assert.AreEqual("Hello RTF World\r\n", plainText); } // ExtractPlainTextTest
} // EnsureDestinationDirectory // ---------------------------------------------------------------------- private IRtfDocument InterpretRtf(IRtfGroup rtfStructure) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if (settings.LogInterpreter) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension); interpreterLogger = new RtfInterpreterListenerFileLogger(logFileName); } // rtf parser // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger); } catch (Exception e) { if (interpreterLogger != null) { interpreterLogger.Dispose(); } Console.WriteLine("error while interpreting rtf: " + e.Message); ExitCode = ProgramExitCode.InterpretRtf; return(null); } return(rtfDocument); } // InterpretRtf
private static IRtfDocument InterpretRtf(IRtfGroup rtfStructure) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // image converter RtfImageConverter imageConverter = null; // rtf parser // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger, imageConverter); } catch (Exception e) { if (interpreterLogger != null) { interpreterLogger.Dispose(); } Console.WriteLine("error while interpreting rtf: " + e.Message); return null; } return rtfDocument; }
// ---------------------------------------------------------------------- public static IRtfGroup GetSupportedDocument( IRtfGroup rtfDocument ) { if ( rtfDocument == null ) { throw new ArgumentNullException( "rtfDocument" ); } if ( rtfDocument.Contents.Count == 0 ) { throw new RtfEmptyDocumentException( Strings.EmptyDocument ); } IRtfElement firstElement = rtfDocument.Contents[ 0 ]; if ( firstElement.Kind != RtfElementKind.Tag ) { throw new RtfStructureException( Strings.MissingDocumentStartTag ); } IRtfTag firstTag = (IRtfTag)firstElement; if ( !RtfSpec.TagRtf.Equals( firstTag.Name ) ) { throw new RtfStructureException( Strings.InvalidDocumentStartTag( RtfSpec.TagRtf ) ); } if ( !firstTag.HasValue ) { throw new RtfUnsupportedStructureException( Strings.MissingRtfVersion ); } if ( firstTag.ValueAsNumber != RtfSpec.RtfVersion1 ) { throw new RtfUnsupportedStructureException( Strings.UnsupportedRtfVersion( firstTag.ValueAsNumber ) ); } return rtfDocument; }
public void TextAlignmentTest() { const RtfParserListenerLogger parserLogger = null; //parserLogger = new RtfParserListenerLogger(); IRtfGroup rtfStructure = RtfParserTool.Parse(GetTestResource("RtfInterpreterTest_3.rtf"), parserLogger); Assert.IsNotNull(rtfStructure); const RtfInterpreterListenerLogger interpreterLogger = null; //interpreterLogger = new RtfInterpreterListenerLogger(); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger); Assert.IsNotNull(rtfDoc); IRtfVisualCollection rtfVisuals = rtfDoc.VisualContent; Assert.AreEqual(8, rtfVisuals.Count); Assert.AreEqual(RtfVisualKind.Text, rtfVisuals[0].Kind); Assert.AreEqual("left aligned", ((IRtfVisualText)rtfVisuals[0]).Text); Assert.AreEqual(RtfTextAlignment.Left, ((IRtfVisualText)rtfVisuals[0]).Format.Alignment); Assert.AreEqual(RtfVisualKind.Text, rtfVisuals[2].Kind); Assert.AreEqual("centered", ((IRtfVisualText)rtfVisuals[2]).Text); Assert.AreEqual(RtfTextAlignment.Center, ((IRtfVisualText)rtfVisuals[2]).Format.Alignment); Assert.AreEqual(RtfVisualKind.Text, rtfVisuals[4].Kind); Assert.AreEqual("right aligned", ((IRtfVisualText)rtfVisuals[4]).Text); Assert.AreEqual(RtfTextAlignment.Right, ((IRtfVisualText)rtfVisuals[4]).Format.Alignment); Assert.AreEqual(RtfVisualKind.Text, rtfVisuals[6].Kind); Assert.AreEqual("block aligned", ((IRtfVisualText)rtfVisuals[6]).Text); Assert.AreEqual(RtfTextAlignment.Justify, ((IRtfVisualText)rtfVisuals[6]).Format.Alignment); } // TextAlignmentTest
} // IsSupportedDocument // ---------------------------------------------------------------------- public static IRtfGroup GetSupportedDocument(IRtfGroup rtfDocument) { if (rtfDocument == null) { throw new ArgumentNullException("rtfDocument"); } if (rtfDocument.Contents.Count == 0) { throw new RtfEmptyDocumentException(Strings.EmptyDocument); } IRtfElement firstElement = rtfDocument.Contents[0]; if (firstElement.Kind != RtfElementKind.Tag) { throw new RtfStructureException(Strings.MissingDocumentStartTag); } IRtfTag firstTag = (IRtfTag)firstElement; if (!RtfSpec.TagRtf.Equals(firstTag.Name)) { throw new RtfStructureException(Strings.InvalidDocumentStartTag(RtfSpec.TagRtf)); } if (!firstTag.HasValue) { throw new RtfUnsupportedStructureException(Strings.MissingRtfVersion); } if (firstTag.ValueAsNumber != RtfSpec.RtfVersion1) { throw new RtfUnsupportedStructureException(Strings.UnsupportedRtfVersion(firstTag.ValueAsNumber)); } return(rtfDocument); } // GetSupportedDocument
public void ImageFormatDecodingTest() { const RtfParserListenerLogger parserLogger = null; //parserLogger = new RtfParserListenerLogger(); const RtfInterpreterListenerLogger interpreterLogger = null; //interpreterLogger = new RtfInterpreterListenerLogger(); // ReSharper disable RedundantExplicitArrayCreation int[] imageResources = new int[] { 4, 5, 6, 7, 8, 19 }; // ReSharper restore RedundantExplicitArrayCreation for (int i = 0; i < imageResources.Length; i++) { string testCaseName = BuildTestResourceName("", imageResources[i], false, "rtf"); IRtfGroup rtfStructure = RtfParserTool.Parse(GetTestResource(testCaseName), parserLogger); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger); Assert.IsNotNull(rtfDoc); bool imageFound = false; foreach (IRtfVisual visual in rtfDoc.VisualContent) { if (visual.Kind == RtfVisualKind.Image) { IRtfVisualImage img = (IRtfVisualImage)visual; Assert.IsNotNull(img.ImageForDrawing); imageFound = true; //Console.WriteLine( "image: " + img.ImageForDrawing ); } } Assert.IsTrue(imageFound, "no image found in test case " + testCaseName); } } // ImageFormatDecodingTest
} // DoVisitGroup // ---------------------------------------------------------------------- protected void VisitGroupChildren( IRtfGroup group ) { foreach ( IRtfElement child in group.Contents ) { child.Visit( this ); } } // VisitGroupChildren
} // Reset // ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { if ( RtfSpec.TagColorTable.Equals( group.Destination ) ) { VisitGroupChildren( group ); } } // DoVisitGroup
} // DoVisitGroup protected void VisitGroupChildren(IRtfGroup group) { foreach (IRtfElement child in group.Contents) { child.Visit(this); } } // VisitGroupChildren
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagUserProperties: VisitGroupChildren( group ); break; case null: Reset(); VisitGroupChildren( group ); collectedProperties.Add( CreateProperty() ); break; case RtfSpec.TagUserPropertyName: textBuilder.Reset(); textBuilder.VisitGroup( group ); propertyName = textBuilder.CombinedText; break; case RtfSpec.TagUserPropertyValue: textBuilder.Reset(); textBuilder.VisitGroup( group ); staticValue = textBuilder.CombinedText; break; case RtfSpec.TagUserPropertyLink: textBuilder.Reset(); textBuilder.VisitGroup( group ); linkValue = textBuilder.CombinedText; break; } }
} // Reset // ---------------------------------------------------------------------- protected override void DoVisitGroup(IRtfGroup group) { switch (group.Destination) { case RtfSpec.TagUserProperties: VisitGroupChildren(group); break; case null: Reset(); VisitGroupChildren(group); this.collectedProperties.Add(CreateProperty()); break; case RtfSpec.TagUserPropertyName: this.textBuilder.Reset(); this.textBuilder.VisitGroup(group); this.propertyName = textBuilder.CombinedText; break; case RtfSpec.TagUserPropertyValue: this.textBuilder.Reset(); this.textBuilder.VisitGroup(group); this.staticValue = textBuilder.CombinedText; break; case RtfSpec.TagUserPropertyLink: this.textBuilder.Reset(); this.textBuilder.VisitGroup(group); this.linkValue = textBuilder.CombinedText; break; } } // DoVisitGroup
} // ExitCode // ---------------------------------------------------------------------- public void Execute() { Console.WriteLine(string.Concat( ApplicationInfo.ShortCaption, ", ", ApplicationInfo.Copyright)); // program settings if (ValidateProgramSettings() == false) { return; } // parse rtf IRtfGroup rtfStructure = ParseRtf(); if (ExitCode != ProgramExitCode.Successfully) { return; } // destination directory EnsureDestinationDirectory(); if (ExitCode != ProgramExitCode.Successfully) { return; } // interpret rtf string text = InterpretRtf(rtfStructure); if (ExitCode != ProgramExitCode.Successfully) { return; } // save text string fileName = SaveText(text); if (ExitCode != ProgramExitCode.Successfully) { return; } // open text file OpenTextFile(fileName); if (ExitCode != ProgramExitCode.Successfully) { return; } // display raw text DisplayRawText(text); if (ExitCode != ProgramExitCode.Successfully) { return; } Console.WriteLine("successfully converted RTF to Raw data in " + settings.DestinationDirectory); } // Execute
public void ImageTest() { const RtfParserListenerLogger parserLogger = null; //parserLogger = new RtfParserListenerLogger(); IRtfGroup rtfStructure = RtfParserTool.Parse(GetTestResource("RtfInterpreterTest_4.rtf"), parserLogger); Assert.IsNotNull(rtfStructure); const RtfInterpreterListenerLogger interpreterLogger = null; //interpreterLogger = new RtfInterpreterListenerLogger(); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger); Assert.IsNotNull(rtfDoc); IRtfVisualCollection rtfVisuals = rtfDoc.VisualContent; Assert.AreEqual(RtfVisualKind.Image, rtfVisuals[4].Kind); IRtfVisualImage img = (IRtfVisualImage)rtfVisuals[4]; Assert.AreEqual(RtfVisualImageFormat.Jpg, img.Format); Assert.AreEqual(100, img.Width); Assert.AreEqual(142, img.Height); Assert.AreEqual(720, img.DesiredWidth); Assert.AreEqual(1020, img.DesiredHeight); } // ImageTest
// ---------------------------------------------------------------------- public string ConvertRtf2Txt(string fileName) { // parser IRtfGroup rtfStructure = ParseRtf(fileName); if (rtfStructure == null) { return(string.Empty); } // interpreter logger RtfInterpreterListenerFileLogger interpreterLogger = null; if (!string.IsNullOrEmpty(InterpreterLogFileName)) { interpreterLogger = new RtfInterpreterListenerFileLogger(InterpreterLogFileName); } // text converter RtfTextConvertSettings textConvertSettings = new RtfTextConvertSettings(); textConvertSettings.BulletText = "-"; RtfTextConverter textConverter = new RtfTextConverter(textConvertSettings); // text interpreter RtfInterpreterTool.Interpret(rtfStructure, interpreterLogger, textConverter); return(textConverter.PlainText); } // ConvertRtf2Txt
} // Reset // ---------------------------------------------------------------------- protected override void DoVisitGroup(IRtfGroup group) { if (RtfSpec.TagColorTable.Equals(group.Destination)) { VisitGroupChildren(group); } } // DoVisitGroup
// ---------------------------------------------------------------------- public void Interpret( IRtfGroup rtfDocument ) { if ( rtfDocument == null ) { throw new ArgumentNullException( "rtfDocument" ); } DoInterpret( rtfDocument ); }
} // RemoveInterpreterListener // ---------------------------------------------------------------------- public void Interpret(IRtfGroup rtfDocument) { if (rtfDocument == null) { throw new ArgumentNullException("rtfDocument"); } DoInterpret(rtfDocument); } // Interpret
// ---------------------------------------------------------------------- protected override void DoVisitGroup(IRtfGroup group) { switch (group.Destination) { case RtfSpec.TagPicture: Reset(); VisitGroupChildren(group); break; } } // DoVisitGroup
} // DoInterpret // ---------------------------------------------------------------------- private void InterpretContents(IRtfGroup rtfDocument) { // by getting here we already know that the given document is supported, and hence // we know it has version 1 Context.Reset(); // clears all previous content and sets the version to 1 lastGroupWasPictureWrapper = false; NotifyBeginDocument(); VisitChildrenOf(rtfDocument); Context.State = RtfInterpreterState.Ended; NotifyEndDocument(); } // InterpretContents
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagInfo: VisitGroupChildren( group ); break; case RtfSpec.TagInfoTitle: this.info.Title = ExtractGroupText( group ); break; case RtfSpec.TagInfoSubject: this.info.Subject = ExtractGroupText( group ); break; case RtfSpec.TagInfoAuthor: this.info.Author = ExtractGroupText( group ); break; case RtfSpec.TagInfoManager: this.info.Manager = ExtractGroupText( group ); break; case RtfSpec.TagInfoCompany: this.info.Company = ExtractGroupText( group ); break; case RtfSpec.TagInfoOperator: this.info.Operator = ExtractGroupText( group ); break; case RtfSpec.TagInfoCategory: this.info.Category = ExtractGroupText( group ); break; case RtfSpec.TagInfoKeywords: this.info.Keywords = ExtractGroupText( group ); break; case RtfSpec.TagInfoComment: this.info.Comment = ExtractGroupText( group ); break; case RtfSpec.TagInfoDocumentComment: this.info.DocumentComment = ExtractGroupText( group ); break; case RtfSpec.TagInfoHyperLinkBase: this.info.HyperLinkbase = ExtractGroupText( group ); break; case RtfSpec.TagInfoCreationTime: this.info.CreationTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoRevisionTime: this.info.RevisionTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoPrintTime: this.info.PrintTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoBackupTime: this.info.BackupTime = ExtractTimestamp( group ); break; } }
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagInfo: VisitGroupChildren( group ); break; case RtfSpec.TagInfoTitle: info.Title = ExtractGroupText( group ); break; case RtfSpec.TagInfoSubject: info.Subject = ExtractGroupText( group ); break; case RtfSpec.TagInfoAuthor: info.Author = ExtractGroupText( group ); break; case RtfSpec.TagInfoManager: info.Manager = ExtractGroupText( group ); break; case RtfSpec.TagInfoCompany: info.Company = ExtractGroupText( group ); break; case RtfSpec.TagInfoOperator: info.Operator = ExtractGroupText( group ); break; case RtfSpec.TagInfoCategory: info.Category = ExtractGroupText( group ); break; case RtfSpec.TagInfoKeywords: info.Keywords = ExtractGroupText( group ); break; case RtfSpec.TagInfoComment: info.Comment = ExtractGroupText( group ); break; case RtfSpec.TagInfoDocumentComment: info.DocumentComment = ExtractGroupText( group ); break; case RtfSpec.TagInfoHyperLinkBase: info.HyperLinkbase = ExtractGroupText( group ); break; case RtfSpec.TagInfoCreationTime: info.CreationTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoRevisionTime: info.RevisionTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoPrintTime: info.PrintTime = ExtractTimestamp( group ); break; case RtfSpec.TagInfoBackupTime: info.BackupTime = ExtractTimestamp( group ); break; } }
} // DoInterpret // ---------------------------------------------------------------------- private void InterpretContents( IRtfGroup rtfDocument ) { // by getting here we already know that the given document is supported, and hence // we know it has version 1 Context.Reset(); // clears all previous content and sets the version to 1 this.lastGroupWasPictureWrapper = false; NotifyBeginDocument(); VisitChildrenOf( rtfDocument ); Context.State = RtfInterpreterState.Ended; NotifyEndDocument(); } // InterpretContents
} // RtfInterpreter // ---------------------------------------------------------------------- public static bool IsSupportedDocument(IRtfGroup rtfDocument) { try { GetSupportedDocument(rtfDocument); } catch (RtfException) { return(false); } return(true); } // IsSupportedDocument
} // EnsureDestinationDirectory // ---------------------------------------------------------------------- private IRtfDocument InterpretRtf(IRtfGroup rtfStructure, IRtfVisualImageAdapter imageAdapter) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if (settings.LogInterpreter) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension); interpreterLogger = new RtfInterpreterListenerFileLogger(logFileName); } // image converter RtfImageConverter imageConverter = null; if (settings.SaveImage) { RtfImageConvertSettings imageConvertSettings = new RtfImageConvertSettings(imageAdapter); imageConvertSettings.ImagesPath = settings.DestinationDirectory; imageConvertSettings.BackgroundColor = settings.ImageBackgroundColor; imageConvertSettings.ScaleImage = !settings.UnscaledImages; if (settings.ExtendedImageScale) { imageConvertSettings.ScaleExtension = 0.5f; } imageConverter = new RtfImageConverter(imageConvertSettings); } // rtf interpreter RtfInterpreterSettings interpreterSettings = new RtfInterpreterSettings(); interpreterSettings.IgnoreDuplicatedFonts = settings.IgnoreDuplicatedFonts; interpreterSettings.IgnoreUnknownFonts = settings.IgnoreUnknownFonts; // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterSettings, interpreterLogger, imageConverter); } catch (Exception e) { if (interpreterLogger != null) { interpreterLogger.Dispose(); } Console.WriteLine("error while interpreting rtf: " + e.Message); ExitCode = ProgramExitCode.InterpretRtf; return(null); } return(rtfDocument); } // InterpretRtf
private IRtfDocument InterpretRtf(IRtfGroup rtfStructure, RtfVisualImageAdapter imageAdapter) { IRtfDocument rtfDocument = null; RtfImageConverter imageConverter = null; RtfImageConvertSettings imageConvertSettings = new RtfImageConvertSettings(imageAdapter); imageConvertSettings.ImagesPath = ImagePath; imageConvertSettings.BackgroundColor = null; imageConverter = new RtfImageConverter(imageConvertSettings); rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, null, imageConverter); return(rtfDocument); }
} // RtfInterpreter // ---------------------------------------------------------------------- public static bool IsSupportedDocument( IRtfGroup rtfDocument ) { try { GetSupportedDocument( rtfDocument ); } catch ( RtfException ) { return false; } return true; } // IsSupportedDocument
public string GetHTML(string rtfString) { ReportProgress(33); IRtfGroup rtfStructure = ParseRtf(rtfString); RtfVisualImageAdapter imageAdapter = new RtfVisualImageAdapter( ImageFileNamePattern, ImageFormat.Jpeg); ReportProgress(33); IRtfDocument rtfDocument = InterpretRtf(rtfStructure, imageAdapter); ReportProgress(33); return(ConvertHmtl(rtfDocument, imageAdapter)); }
} // SetupDefaultText // ---------------------------------------------------------------------- private void ToTextButtonClick(object sender, EventArgs e) { try { IRtfGroup rtfStructure = RtfParserTool.Parse(ConversionText); RtfTextConverter textConverter = new RtfTextConverter(); RtfInterpreterTool.Interpret(rtfStructure, textConverter); textBox.Text = textConverter.PlainText; } catch (Exception exception) { MessageBox.Show(this, "Error " + exception.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } // ToTextButtonClick
// ---------------------------------------------------------------------- public void VisitGroup( IRtfGroup group ) { if ( group != null ) { if ( order == RtfElementVisitorOrder.DepthFirst ) { VisitGroupChildren( group ); } DoVisitGroup( group ); if ( order == RtfElementVisitorOrder.BreadthFirst ) { VisitGroupChildren( group ); } } }
} // VisitTag public void VisitGroup(IRtfGroup group) { if (group != null) { if (_order == RtfElementVisitorOrder.DepthFirst) { VisitGroupChildren(group); } DoVisitGroup(group); if (_order == RtfElementVisitorOrder.BreadthFirst) { VisitGroupChildren(group); } } } // VisitGroup
} // EnsureDestinationDirectory // ---------------------------------------------------------------------- private IRtfDocument InterpretRtf(IRtfGroup rtfStructure, IRtfVisualImageAdapter imageAdapter) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if (settings.LogInterpreter) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension); interpreterLogger = new RtfInterpreterListenerFileLogger(logFileName); } // image converter RtfImageConverter imageConverter = null; if (settings.SaveImage) { RtfImageConvertSettings imageConvertSettings = new RtfImageConvertSettings(imageAdapter); imageConvertSettings.ImagesPath = settings.DestinationDirectory; imageConvertSettings.BackgroundColor = settings.ImageBackgroundColor; if (settings.ExtendedImageScale) { imageConvertSettings.ScaleExtension = 0.5f; } imageConverter = new RtfImageConverter(imageConvertSettings); } // rtf parser // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger, imageConverter); } catch (Exception e) { if (interpreterLogger != null) { interpreterLogger.Dispose(); } MessageBox(IntPtr.Zero, "Error while interpreting RTF:\n" + e.Message, "Itenso.Rtf2Html", 0x010000); ExitCode = ProgramExitCode.InterpretRtf; return(null); } return(rtfDocument); } // InterpretRtf
} // Interpret // ---------------------------------------------------------------------- public static void Interpret(IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners) { RtfInterpreter parser = new RtfInterpreter(); if (listeners != null) { foreach (IRtfInterpreterListener listener in listeners) { if (listener != null) { parser.AddInterpreterListener(listener); } } } parser.Interpret(rtfDocument); } // Interpret
} // Reset // ---------------------------------------------------------------------- protected override void DoVisitGroup(IRtfGroup group) { switch (group.Destination) { case RtfSpec.TagFont: case RtfSpec.TagThemeFontLoMajor: case RtfSpec.TagThemeFontHiMajor: case RtfSpec.TagThemeFontDbMajor: case RtfSpec.TagThemeFontBiMajor: case RtfSpec.TagThemeFontLoMinor: case RtfSpec.TagThemeFontHiMinor: case RtfSpec.TagThemeFontDbMinor: case RtfSpec.TagThemeFontBiMinor: BuildFontFromGroup(group); break; case RtfSpec.TagFontTable: if (group.Contents.Count > 1) { if (group.Contents[1].Kind == RtfElementKind.Group) { // the 'new' style where each font resides in a group of its own VisitGroupChildren(group); } else { // the 'old' style where individual fonts are 'terminated' by their // respective name content text (which ends with ';') // -> need to manually iterate from here int childCount = group.Contents.Count; fontBuilder.Reset(); for (int i = 1; i < childCount; i++) // skip over the initial \fonttbl tag { group.Contents[i].Visit(fontBuilder); if (fontBuilder.FontName != null) { // fonts are 'terminated' by their name (as content text) AddCurrentFont(); fontBuilder.Reset(); } } //BuildFontFromGroup( group ); // a single font info } } break; } } // DoVisitGroup
private static IRtfDocument InterpretRtf(IRtfGroup rtfStructure, IRtfVisualImageAdapter imageAdapter, string imageAdapterLogFile = null, RtfImageConvertSettings imageConvertSettings = null, bool throwOnError = false) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if (imageAdapterLogFile != null) { interpreterLogger = new RtfInterpreterListenerFileLogger(imageAdapterLogFile); } // image converter RtfImageConverter imageConverter = null; if (imageConvertSettings != null) { imageConverter = new RtfImageConverter(imageConvertSettings); } // rtf interpreter RtfInterpreterSettings interpreterSettings = new RtfInterpreterSettings(); interpreterSettings.IgnoreDuplicatedFonts = true; interpreterSettings.IgnoreUnknownFonts = true; // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterSettings, interpreterLogger, imageConverter); } catch (Exception e) { if (interpreterLogger != null) { interpreterLogger.Dispose(); } if (throwOnError) { ThrowOnUnexpectedExitCode(e); } return(null); } return(rtfDocument); }
} // Interpret // ---------------------------------------------------------------------- public static void Interpret(IRtfGroup rtfDocument, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners) { RtfInterpreter interpreter = new RtfInterpreter(settings); if (listeners != null) { foreach (IRtfInterpreterListener listener in listeners) { if (listener != null) { interpreter.AddInterpreterListener(listener); } } } interpreter.Interpret(rtfDocument); } // Interpret
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagFont: case RtfSpec.TagThemeFontLoMajor: case RtfSpec.TagThemeFontHiMajor: case RtfSpec.TagThemeFontDbMajor: case RtfSpec.TagThemeFontBiMajor: case RtfSpec.TagThemeFontLoMinor: case RtfSpec.TagThemeFontHiMinor: case RtfSpec.TagThemeFontDbMinor: case RtfSpec.TagThemeFontBiMinor: BuildFontFromGroup( group ); break; case RtfSpec.TagFontTable: if ( group.Contents.Count > 1 ) { if ( group.Contents[ 1 ].Kind == RtfElementKind.Group ) { // the 'new' style where each font resides in a group of its own VisitGroupChildren( group ); } else { // the 'old' style where individual fonts are 'terminated' by their // respective name content text (which ends with ';') // -> need to manually iterate from here int childCount = group.Contents.Count; fontBuilder.Reset(); for ( int i = 1; i < childCount; i++ ) // skip over the initial \fonttbl tag { group.Contents[ i ].Visit( fontBuilder ); if ( fontBuilder.FontName != null ) { // fonts are 'terminated' by their name (as content text) AddCurrentFont(); fontBuilder.Reset(); } } //BuildFontFromGroup( group ); // a single font info } } break; } }
// ---------------------------------------------------------------------- public static IRtfDocument BuildDoc( IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners ) { RtfInterpreterListenerDocumentBuilder docBuilder = new RtfInterpreterListenerDocumentBuilder(); IRtfInterpreterListener[] allListeners; if ( listeners == null ) { allListeners = new IRtfInterpreterListener[] { docBuilder }; } else { allListeners = new IRtfInterpreterListener[ listeners.Length + 1 ]; allListeners[ 0 ] = docBuilder; listeners.CopyTo( allListeners, 1 ); } Interpret( rtfDocument, allListeners ); return docBuilder.Document; }
} // Reset // ---------------------------------------------------------------------- protected override void DoVisitGroup(IRtfGroup group) { switch (group.Destination) { case RtfSpec.TagFont: case RtfSpec.TagThemeFontLoMajor: case RtfSpec.TagThemeFontHiMajor: case RtfSpec.TagThemeFontDbMajor: case RtfSpec.TagThemeFontBiMajor: case RtfSpec.TagThemeFontLoMinor: case RtfSpec.TagThemeFontHiMinor: case RtfSpec.TagThemeFontDbMinor: case RtfSpec.TagThemeFontBiMinor: VisitGroupChildren(group); break; } } // DoVisitGroup
} // BuildDoc // ---------------------------------------------------------------------- public static IRtfDocument BuildDoc(IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners) { RtfInterpreterListenerDocumentBuilder docBuilder = new RtfInterpreterListenerDocumentBuilder(); IRtfInterpreterListener[] allListeners; if (listeners == null) { allListeners = new IRtfInterpreterListener[] { docBuilder }; } else { allListeners = new IRtfInterpreterListener[listeners.Length + 1]; allListeners[0] = docBuilder; listeners.CopyTo(allListeners, 1); } Interpret(rtfDocument, allListeners); return(docBuilder.Document); } // BuildDoc
} // IsExtensionDestination // ---------------------------------------------------------------------- public IRtfGroup SelectChildGroupWithDestination(string destination) { if (destination == null) { throw new ArgumentNullException("destination"); } foreach (IRtfElement child in this.contents) { if (child.Kind == RtfElementKind.Group) { IRtfGroup group = (IRtfGroup)child; if (destination.Equals(group.Destination)) { return(group); } } } return(null); } // SelectChildGroupWithDestination
private static bool BuildHtmlContent(IRtfGroup content, XmlWriter writer) { var nodesFound = false; bool doRender = false; foreach (IRtfElement elem in content.Contents) { switch (elem.Kind) { case RtfElementKind.Group: nodesFound = BuildHtmlContent((IRtfGroup)elem, writer) || nodesFound; break; case RtfElementKind.Text: if (doRender) { writer.WriteRaw(((IRtfText)elem).Text); nodesFound = true; } break; case RtfElementKind.Tag: switch (((IRtfTag)elem).Name) { case "htmltag": case "htmlrtf": doRender = !doRender; break; case "par": if (doRender) { writer.WriteRaw("\r\n"); nodesFound = true; } break; } break; } } return(nodesFound); }
// ---------------------------------------------------------------------- void IRtfElementVisitor.VisitGroup( IRtfGroup group ) { string groupDestination = group.Destination; switch ( Context.State ) { case RtfInterpreterState.Init: if ( RtfSpec.TagRtf.Equals( groupDestination ) ) { VisitChildrenOf( group ); } else { throw new RtfStructureException( Strings.InvalidInitGroupState( groupDestination ) ); } break; case RtfInterpreterState.InHeader: switch ( groupDestination ) { case RtfSpec.TagFontTable: fontTableBuilder.VisitGroup( group ); break; case RtfSpec.TagColorTable: colorTableBuilder.VisitGroup( group ); break; case RtfSpec.TagGenerator: // last group with a destination in header, but no need to process its contents Context.State = RtfInterpreterState.InDocument; IRtfText generator = group.Contents.Count == 3 ? group.Contents[ 2 ] as IRtfText : null; if ( generator != null ) { string generatorName = generator.Text; Context.Generator = generatorName.EndsWith( ";" ) ? generatorName.Substring( 0, generatorName.Length - 1 ) : generatorName; } else { throw new RtfInvalidDataException( Strings.InvalidGeneratorGroup( group.ToString() ) ); } break; case RtfSpec.TagPlain: case RtfSpec.TagParagraphDefaults: case RtfSpec.TagSectionDefaults: case RtfSpec.TagUnderLineNone: case null: // <tags>: special tags commonly used to reset state in a beginning group. necessary to recognize // state transition form header to document in case no other mechanism detects it and the // content starts with a group with such a 'destination' ... // 'null': group without destination cannot be part of header, but need to process its contents Context.State = RtfInterpreterState.InDocument; if ( !group.IsExtensionDestination ) { VisitChildrenOf( group ); } break; } break; case RtfInterpreterState.InDocument: switch ( groupDestination ) { case RtfSpec.TagUserProperties: userPropertyBuilder.VisitGroup( group ); break; case RtfSpec.TagInfo: documentInfoBuilder.VisitGroup( group ); break; case RtfSpec.TagUnicodeAlternativeChoices: IRtfGroup alternativeWithUnicodeSupport = group.SelectChildGroupWithDestination( RtfSpec.TagUnicodeAlternativeUnicode ); if ( alternativeWithUnicodeSupport != null ) { // there is an alternative with unicode formatted content -> use this VisitChildrenOf( alternativeWithUnicodeSupport ); } else { // try to locate the alternative without unicode -> only ANSI fallbacks IRtfGroup alternativeWithoutUnicode = // must be the third element if present group.Contents.Count > 2 ? group.Contents[ 2 ] as IRtfGroup : null; if ( alternativeWithoutUnicode != null ) { VisitChildrenOf( alternativeWithoutUnicode ); } } break; case RtfSpec.TagHeader: case RtfSpec.TagHeaderFirst: case RtfSpec.TagHeaderLeft: case RtfSpec.TagHeaderRight: case RtfSpec.TagFooter: case RtfSpec.TagFooterFirst: case RtfSpec.TagFooterLeft: case RtfSpec.TagFooterRight: case RtfSpec.TagFootnote: case RtfSpec.TagStyleSheet: // groups we currently ignore, so their content doesn't intermix with // the actual document content break; case RtfSpec.TagPictureWrapper: VisitChildrenOf( group ); lastGroupWasPictureWrapper = true; break; case RtfSpec.TagPictureWrapperAlternative: if ( !lastGroupWasPictureWrapper ) { VisitChildrenOf( group ); } lastGroupWasPictureWrapper = false; break; case RtfSpec.TagPicture: imageBuilder.VisitGroup( group ); NotifyInsertImage( imageBuilder.Format, imageBuilder.Width, imageBuilder.Height, imageBuilder.DesiredWidth, imageBuilder.DesiredHeight, imageBuilder.ScaleWidthPercent, imageBuilder.ScaleHeightPercent, imageBuilder.ImageDataHex ); break; case RtfSpec.TagParagraphNumberText: case RtfSpec.TagListNumberText: NotifyInsertSpecialChar( RtfVisualSpecialCharKind.ParagraphNumberBegin ); VisitChildrenOf( group ); NotifyInsertSpecialChar( RtfVisualSpecialCharKind.ParagraphNumberEnd ); break; default: if ( !group.IsExtensionDestination ) { // nested text group VisitChildrenOf( group ); } break; } break; } }
// ---------------------------------------------------------------------- protected abstract void DoInterpret( IRtfGroup rtfDocument );
// ---------------------------------------------------------------------- private string InterpretRtf( IRtfGroup rtfStructure ) { string text = null; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if ( settings.LogInterpreter ) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension ); interpreterLogger = new RtfInterpreterListenerFileLogger( logFileName ); } // text converter RtfTextConverter textConverter = null; if ( settings.SaveText ) { RtfTextConvertSettings textConvertSettings = new RtfTextConvertSettings(); textConvertSettings.IsShowHiddenText = settings.ShowHiddenText; textConverter = new RtfTextConverter( textConvertSettings ); } // image converter RtfImageConverter imageConverter = null; if ( settings.SaveImage ) { RtfVisualImageAdapter imageAdapter = new RtfVisualImageAdapter( settings.ImageFileNamePattern, settings.ImageFormat ); RtfImageConvertSettings imageConvertSettings = new RtfImageConvertSettings( imageAdapter ); imageConvertSettings.ImagesPath = settings.DestinationDirectory; imageConvertSettings.ScaleImage = settings.ScaleImage; imageConvertSettings.BackgroundColor = settings.ImageBackgroundColor; if ( settings.ExtendedImageScale ) { imageConvertSettings.ScaleExtension = 0.5f; } imageConverter = new RtfImageConverter( imageConvertSettings ); } // rtf parser // interpret the rtf structure using the extractors RtfInterpreterTool.Interpret( rtfStructure, interpreterLogger, textConverter, imageConverter ); // get the resulting text if ( textConverter != null ) { text = textConverter.PlainText; } } catch ( Exception e ) { if ( interpreterLogger != null ) { interpreterLogger.Dispose(); } Console.WriteLine( "error while interpreting rtf: " + e.Message ); ExitCode = ProgramExitCode.InterpretRtf; return null; } return text; }
// ---------------------------------------------------------------------- private DateTime ExtractTimestamp( IRtfGroup group ) { timestampBuilder.Reset(); timestampBuilder.VisitGroup( group ); return timestampBuilder.CreateTimestamp(); }
// ---------------------------------------------------------------------- public static void Interpret( IRtfGroup rtfDocument, IRtfInterpreterSettings settings, params IRtfInterpreterListener[] listeners) { RtfInterpreter interpreter = new RtfInterpreter( settings ); if ( listeners != null ) { foreach ( IRtfInterpreterListener listener in listeners ) { if ( listener != null ) { interpreter.AddInterpreterListener( listener ); } } } interpreter.Interpret( rtfDocument ); }
// ---------------------------------------------------------------------- private IRtfDocument InterpretRtf( IRtfGroup rtfStructure, IRtfVisualImageAdapter imageAdapter ) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if ( settings.LogInterpreter ) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension ); interpreterLogger = new RtfInterpreterListenerFileLogger( logFileName ); } // image converter RtfImageConverter imageConverter = null; if ( settings.SaveImage ) { RtfImageConvertSettings imageConvertSettings = new RtfImageConvertSettings( imageAdapter ); imageConvertSettings.ImagesPath = settings.DestinationDirectory; imageConvertSettings.BackgroundColor = settings.ImageBackgroundColor; if ( settings.ExtendedImageScale ) { imageConvertSettings.ScaleExtension = 0.5f; } imageConverter = new RtfImageConverter( imageConvertSettings ); } // rtf parser // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc( rtfStructure, interpreterLogger, imageConverter ); } catch ( Exception e ) { if ( interpreterLogger != null ) { interpreterLogger.Dispose(); } Console.WriteLine( "error while interpreting rtf: " + e.Message ); ExitCode = ProgramExitCode.InterpretRtf; return null; } return rtfDocument; }
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagFont: case RtfSpec.TagThemeFontLoMajor: case RtfSpec.TagThemeFontHiMajor: case RtfSpec.TagThemeFontDbMajor: case RtfSpec.TagThemeFontBiMajor: case RtfSpec.TagThemeFontLoMinor: case RtfSpec.TagThemeFontHiMinor: case RtfSpec.TagThemeFontDbMinor: case RtfSpec.TagThemeFontBiMinor: VisitGroupChildren( group ); break; } }
// ---------------------------------------------------------------------- public static void Interpret( IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners ) { RtfInterpreter parser = new RtfInterpreter(); if ( listeners != null ) { foreach ( IRtfInterpreterListener listener in listeners ) { if ( listener != null ) { parser.AddInterpreterListener( listener ); } } } parser.Interpret( rtfDocument ); }
// ---------------------------------------------------------------------- private IRtfDocument InterpretRtf( IRtfGroup rtfStructure ) { IRtfDocument rtfDocument; RtfInterpreterListenerFileLogger interpreterLogger = null; try { // logger if ( settings.LogInterpreter ) { string logFileName = settings.BuildDestinationFileName( settings.LogDirectory, RtfInterpreterListenerFileLogger.DefaultLogFileExtension ); interpreterLogger = new RtfInterpreterListenerFileLogger( logFileName ); } // rtf parser // interpret the rtf structure using the extractors rtfDocument = RtfInterpreterTool.BuildDoc( rtfStructure, interpreterLogger ); } catch ( Exception e ) { if ( interpreterLogger != null ) { interpreterLogger.Dispose(); } Console.WriteLine( "error while interpreting rtf: " + e.Message ); ExitCode = ProgramExitCode.InterpretRtf; return null; } return rtfDocument; }
// ---------------------------------------------------------------------- protected override void DoInterpret( IRtfGroup rtfDocument ) { InterpretContents( GetSupportedDocument( rtfDocument ) ); }
// ---------------------------------------------------------------------- private void BuildFontFromGroup( IRtfGroup group ) { fontBuilder.Reset(); fontBuilder.VisitGroup( group ); AddCurrentFont(); }
// ---------------------------------------------------------------------- private void VisitChildrenOf( IRtfGroup group ) { bool pushedTextFormat = false; if ( Context.State == RtfInterpreterState.InDocument ) { Context.PushCurrentTextFormat(); pushedTextFormat = true; } try { foreach ( IRtfElement child in group.Contents ) { child.Visit( this ); } } finally { if ( pushedTextFormat ) { Context.PopCurrentTextFormat(); } } }
// ---------------------------------------------------------------------- protected override void DoVisitGroup( IRtfGroup group ) { switch ( group.Destination ) { case RtfSpec.TagPicture: Reset(); VisitGroupChildren( group ); break; } }
// ---------------------------------------------------------------------- public static IRtfDocument BuildDoc( IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners ) { return BuildDoc( rtfDocument, new RtfInterpreterSettings(), listeners ); }
// ---------------------------------------------------------------------- protected virtual void DoVisitGroup( IRtfGroup group ) { }
// ---------------------------------------------------------------------- public static void Interpret( IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners ) { Interpret( rtfDocument, new RtfInterpreterSettings(), listeners ); }
// ---------------------------------------------------------------------- private string ExtractGroupText( IRtfGroup group ) { textBuilder.Reset(); textBuilder.VisitGroup( group ); return textBuilder.CombinedText; }