You must Sign In to post a response.
  • Category: ASP.NET

    Convert pdf to excel using C#

    Hi

    I need Convert PDF file into Excel file in C#. Please let me know how to achieve it?

    I dont want to use any third party paid dll for this. Is it feasible?


    Thanks!
    Best Regards,
    Anjali Bansal
  • #767855
    Hi,

    I have tried the below solution once and it worked for me.

    http://www.codeproject.com/Questions/660626/convert-pdf-file-into-excel-sheet

    Kindly check this out.

    Note:
    Most of them are using 3rd party tool for this. Which is simple and free too.

    Thanks,
    Mani

  • #767865
    Hi,

    First extract data from pdf using PdfTextExtractor.GetTextFromPage method to some object like stringbuilder like below,


    StringBuilder text = new StringBuilder();
    PdfReader pdfReader = new PdfReader(fileName);
    for (int page = 1; page <= pdfReader.NumberOfPages; page++)
    {
    ITextExtractionStrategy strategy = new LocationTextExtractionStrategy();
    string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
    currentText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.UTF8.GetBytes(currentText)));
    text.Append(currentText);
    pdfReader.Close();
    }


    once you got the result set into stringbuilder then you can export it into excel as usual, refer below link for more details.

    aspforums.net/Threads/180443/Convert-a-PDF-File-to-Excel-File-using-iTextSharp-using-C-Net/

    Hope this helps you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments