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,


Hello! I am doing exactly the process you describe above, however, the table absorber is only seeing 3 or 4 fragments of the cells. I have cells where I can manually count 10 fragments but it only reads the first 3 or 4. Any suggestions?

@juanolano

Are you using a valid or 30-days free temporary license? Please share your sample PDF so that we can test the scenario in our environment and address it accordingly.

I am using a full license I purchased today. This problem was solved with the full problem but a new problem arised and I created a case for it and attached pdf. Thank you for your response!

@juanolano

Sure, you will be updated in the other ticket that you have opened in our forum.