Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Remove all text from page with TextFragmentCollection is to slow

$
0
0
Hello,

I'm trying to remove all text from a page using the following code but it's to slow on some pages that contains a lot of text/links. Is there a faster way to just remove the text from PDF? Also, is there anyway to add the textFragment to another PDF before I remove it? Like copy fragment on another variable and add that to the second PDF Document? My try has failed in doing so...

        Aspose.Pdf.Text.TextFragmentAbsorber textFragmentAbsorber = new Aspose.Pdf.Text.TextFragmentAbsorber();
        pdfDocument.Pages[i].Accept(textFragmentAbsorber);
        Aspose.Pdf.Text.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

        foreach (Aspose.Pdf.Text.TextFragment textFragment in textFragmentCollection)
        {
           //Create TextBuilder object
           //Aspose.Pdf.Text.TextBuilder textBuilder = new Aspose.Pdf.Text.TextBuilder(newDocument.Pages[i]);
            //Append the text fragment to the new PDF page
           //textBuilder.AppendText(textFragment); //doesn't work, it doesn't append text to the new pdf document... maybe because it get's cleared bellow?
                                                      
                textFragment.Text = "";  //to slow removing each fragment for all pages


        }


Thank you,
Razvan

Viewing all articles
Browse latest Browse all 3131

Trending Articles