Extract text based on columns - very slow

I'm with the PDF version and I am trying to extract every page of a PDF 3mb in which it has multi columns (in a few pages, and not always the same amount of columns).

This PDF (attached) is one of the smallest I have, because I need to read other 30mb.
I'm using the piece of code below, but upon entering the loop, no out more.

How to solve?

string path = "D:\\Temp\\";
Document pdfDocument = new Document(path + "net_New-age NED's.pdf");

TextFragmentAbsorber tfa = new TextFragmentAbsorber();
TextFragmentCollection tfc = tfa.TextFragments;
foreach (TextFragment tf in tfc)
//need to reduce font size at least for 70%
tf.TextState.FontSize = tf.TextState.FontSize * 0.7f;
Stream st = new MemoryStream();
pdfDocument = new Document(st);

TextAbsorber textAbsorber = new TextAbsorber();
String extractedText = textAbsorber.Text;

System.IO.File.WriteAllText(path + "Extracted.txt", extractedText);

Hi Marco,

Thanks for your inquiry. We have manged to notice performance issue with text extraction from shared PDF document. So we have logged a ticket PDFNEWNET-39090 for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,


Thanks for your patience.

Changing font size of the multitude of text fragments is time consuming operation. To improve formatted text extraction result for text containing columns, we have introduced TextExtractionOptions.ScaleFactor option. It makes ‘virtual’ scaling (decreasing) of font size without actual changes in the document. It produces effect on text extraction result that almost equivalent to changing font size but works much more faster.

Please also take into account that ‘pdfDocument.Pages.Accept(textAbsorber);’ and ‘textAbsorber.Visit(pdfDocument);’ is two different call of single function (text extraction). Using both of them is unnecessary and spends processing time.

Please consider the following code:

Stopwatch sw = new Stopwatch();

Document pdfDocument = new Document(myDir + "DOAL-03-07-2015.pdf");

TextExtractionOptions options = new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Pure);
options.ScaleFactor = 0.5;

TextAbsorber textAbsorber = new TextAbsorber();
textAbsorber.ExtractionOptions = options;

String extractedText = textAbsorber.Text;

System.IO.File.WriteAllText(myDir + "Extracted.txt", extractedText);


In our test system, above code snippet took ~10 Seconds to execute. Output files are also attached for your reference.

OutputFiles.zip (529.7 KB)

Please use above code snippet with Aspose.PDF for .NET 18.12 and in case of any further assistance, please feel free to let us know.