Hello,
I am getting "Index Out of Bound" error while replace email address in PDF file and then save it to html format.
I am using below code :
//open documentDocument pdfDocument = new Document("input.pdf");//create TextAbsorber object to find all instances of the input search phraseTextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000//set text search option to specify regular expression usageTextSearchOptions textSearchOptions = new TextSearchOptions(true); textFragmentAbsorber.TextSearchOptions = textSearchOptions;//accept the absorber for all the pagespdfDocument.Pages.Accept(textFragmentAbsorber);//get the extracted text fragmentsTextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;//loop through the fragmentsforeach (TextFragment textFragment in textFragmentCollection) {//update text and other propertiestextFragment.Text = "New Phrase"; set to an instance of an object. textFragment.TextState.Font = FontRepository.FindFont("Verdana"); textFragment.TextState.FontSize = 22; textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue); textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); }
HtmlSaveOptions htmlOptions = new HtmlSaveOptions(); htmlOptions.FixedLayout = true; htmlOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsTTF; htmlOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
pdfDocument.Save("output.html",htmlOptions);
Please reply As soon as possible.
Thanks,
Jignesh Chauhan