How to Convert PDF to CSV using C#

This basic tutorial guides on how to convert PDF to CSV using C# by providing configuration steps along with a runnable sample code. It describes how using C# PDF to CSV conversion can be performed by loading the source PDF and then setting parameters of the output Excel file in CSV format. After the configuration, the CSV file is generated from the PDF and saved on disk.

Steps to Convert PDF to CSV using C#

  1. Add a reference to Aspose.PDF into your project to convert PDF to CSV
  2. Load the source PDF file into the Document class object for conversion to CSV
  3. Instantiate the ExcelSaveOptions class object to define the output file format and other parameters
  4. Save the input PDF as a CSV file using the desired configuration

These steps provide information about the configuration of the project by adding the required libraries to the project. In the next step, the source PDF file is loaded into the document class object however there are many other formats also that can be used. In the end, the output file can be saved as CSV or into other MS Excel supported formats.

Code to Convert PDF to CSV using C#

To convert PDF to CSV C# code is used here that uses Document class object to load source PDF file from the disk however it can be loaded from a stream also. There are many other formats that are supported for loading the files into Document class like CGM, HTML, EPUB, XML, etc. using the respective LoadOptions class. Similarly, you may configure the output Excel file by minimizing the number of worksheets, setting uniform worksheets, inserting blank columns at first, and even setting the output format to XLSX, XLSM, ODS, XMLSpreadSheet2003 instead of CSV.

In this article, we have learned how to convert PDF to CSV using C#. If you want to learn the conversion of PDF to image, refer to the article on how to convert PDF to image in C#.

 English