PDF to CSV API in C# with PDF.co Web API

Tutorial: how to do PDF to CSV API in C#

The sample source codes on this page will demonstrate you how to make PDF to CSV API in C#. PDF.co Web API was made to help with PDF to CSV API in C#. PDF.co Web API is the Web API with a set of tools for documents manipulation, data conversion, data extraction, splitting and merging of documents. Includes image recognition, built-in OCR, barcode generation and barcode decoders to decode bar codes from scans, pictures and pdf.

C#, code samples for C#, developers help to speed up the application development and writing a code when using PDF.co Web API. In order to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. Further enhancement of the code will make it more vigorous.

Trial version can be obtained from our website for free. It includes this and other source code samples for C#.

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Program.cs
      
using System; using System.IO; using System.Net; using Newtonsoft.Json.Linq; namespace ByteScoutWebApiExample { class Program { // The authentication key (API Key). // Get your own by registering at https://app.pdf.co/documentation/api const String API_KEY = "**************************************"; // Direct URL of source PDF file. const string SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-csv/sample.pdf"; // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. const string Pages = ""; // PDF document password. Leave empty for unprotected documents. const string Password = ""; // Destination CSV file name const string DestinationFile = @".\result.csv"; // Sample profile that sets advanced conversion options // Advanced options are properties of CSVExtractor class from ByteScout PDF Extractor SDK used in the back-end: // https://cdn.bytescout.com/help/BytescoutPDFExtractorSDK/html/87ce5fa6-3143-167d-abbd-bc7b5e160fe5.htm static string Profiles = File.ReadAllText("profile.json"); static void Main(string[] args) { // Create standard .NET web client instance WebClient webClient = new WebClient(); // Set API Key webClient.Headers.Add("x-api-key", API_KEY); // Prepare URL for `PDF To CSV` API call string query = Uri.EscapeUriString(string.Format( "https://api.pdf.co/v1/pdf/convert/to/csv?name={0}&password={1}&pages={2}&url={3}&profiles={4}", Path.GetFileName(DestinationFile), Password, Pages, SourceFileUrl, Profiles)); try { // Execute request string response = webClient.DownloadString(query); // Parse JSON response JObject json = JObject.Parse(response); if (json["status"].ToString() != "error") { // Get URL of generated CSV file string resultFileUrl = json["url"].ToString(); // Download CSV file webClient.DownloadFile(resultFileUrl, DestinationFile); Console.WriteLine("Generated CSV file saved as \"{0}\" file.", DestinationFile); } else { Console.WriteLine(json["message"].ToString()); } } catch (WebException e) { Console.WriteLine(e.ToString()); } webClient.Dispose(); Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); } } }

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

packages.config
      
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" /> </packages>

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Get PDF.co Web API Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Related Samples: