Free Support Forum - aspose.com

Regarding TextFragment is not able to read whole content of a column

Hi,


PFA


I am trying to extract text of column using TextFragment[1].Text but sometime its return me only few character of content why this happening occur i have no idea. Do u provide me a solution for this.

Hi Karambir,


Thanks for your inquiry. You are extracting only first TextFragement from TextFragment Collection so your are not getting complete data. Please check following sample code, hopefully it will help you to accomplish the task.

// Source PDF file<o:p></o:p>

Document pdfDocument = new Document(myDir + "asset_102826BuffaloDippingSauceK12.pdf");

TableAbsorber absorber = new TableAbsorber();

// Visit first page with absorber

for (int pages = 1; pages <= pdfDocument.Pages.Count; pages++)

{

absorber.Visit(pdfDocument.Pages[pages]);

// Get access to first table on page, their first cell and text fragments in it

//iterate through each table of pdf

for (int i = 0; i < absorber.TableList.Count; i++)

{

//iterate through each row of table

for (int j = 0; j < absorber.TableList[i].RowList.Count; j++)

{

//iterate through each cell of row

for (int k = 0; k < absorber.TableList[i].RowList[j].CellList.Count; k++)

{

//iterate through each cell to extract data

if (absorber.TableList[i].RowList[j].CellList[k].TextFragments.Count > 0)

{

//TextFragment fragment = absorber.TableList[i].RowList[j].CellList[k].TextFragments[1];

var textFragmentCollection = absorber.TableList[i].RowList[j].CellList[k].TextFragments;

string s = null;

foreach (TextFragment fragment in textFragmentCollection)

{

s = s + fragment.Text;

}

Console.WriteLine("Table {0},Row {1}, Cell {2},Text: {3}", i, j, k, s);

}

}

}

}

}

Please feel free to contact us for any further assistance.


Best Regards,

Hi,

Thanks for help.
Its Working.

Hi Karambir,


Thanks for your feedback. It is good to know that you have manged to accomplish your requirement.

Please keep using Aspose and feel free to contact us for any further assistance.

Best Regards,