ByteScout Data Extraction Suite - C++ - Find Table And Extract As CSV from PDF with PDF Extractor SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Data Extraction Suite – C++ – Find Table And Extract As CSV from PDF with PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – C++ – Find Table And Extract As CSV from PDF with PDF Extractor SDK

How to find table and extract as CSV from PDF with PDF extractor SDK in C++ with ByteScout Data Extraction Suite

Learn to find table and extract as CSV from PDF with PDF extractor SDK in C++

Every ByteScout tool includes simple example C++ source codes that you can get here or in the folder with installed ByteScout product. What is ByteScout Data Extraction Suite? It is the set that includes 3 SDK products for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK. It can help you to find table and extract as CSV from PDF with PDF extractor SDK in your C++ application.

Want to quickly learn? This fast application programming interfaces of ByteScout Data Extraction Suite for C++ plus the guidelines and the code below will help you quickly learn how to find table and extract as CSV from PDF with PDF extractor SDK. Follow the instructions from scratch to work and copy the C++ code. Complete and detailed tutorials and documentation are available along with installed ByteScout Data Extraction Suite if you’d like to learn more about the topic and the details of the API.

If you want to try other source code samples then the free trial version of ByteScout Data Extraction Suite is available for download from our website. Just try other source code samples for C++.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

FindTableAndExtractAsCsv.cpp
      
#include "stdafx.h" #include "comip.h" #import "c:\\Program Files\\Bytescout PDF Extractor SDK\\net4.00\\Bytescout.PDFExtractor.tlb" raw_interfaces_only using namespace Bytescout_PDFExtractor; int _tmain(int argc, _TCHAR* argv[]) { // Initialize COM. HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // Create CSVExtractor instance _CSVExtractorPtr pICSVExtractor(__uuidof(CSVExtractor)); pICSVExtractor->put_RegistrationName(_bstr_t(L"DEMO")); pICSVExtractor->put_RegistrationKey(_bstr_t(L"DEMO")); // Create TableDetector instance _TableDetectorPtr pITableDetector(__uuidof(TableDetector)); pITableDetector->put_RegistrationName(_bstr_t(L"DEMO")); pITableDetector->put_RegistrationKey(_bstr_t(L"DEMO")); // Set table detection mode to "bordered tables" - best for tables with closed solid borders. pITableDetector->put_ColumnDetectionMode(ColumnDetectionMode_BorderedTables); // We should define what kind of tables we should detect. // So we set min required number of columns to 2 ... pITableDetector->put_DetectionMinNumberOfColumns(2); // ... and we set min required number of rows to 2 pITableDetector->put_DetectionMinNumberOfRows(2); // Load sample PDF document _bstr_t inputFile(L"..\\..\\sample3.pdf"); pICSVExtractor->LoadDocumentFromFile(inputFile); pITableDetector->LoadDocumentFromFile(inputFile); // Get page count long pageCount; pITableDetector->GetPageCount(&pageCount); for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { int t = 1; VARIANT_BOOL vbResult; // Find first table and continue if found pITableDetector->FindTable(pageIndex, &vbResult); if (vbResult == VARIANT_TRUE) { do { float left, top, width, height; pITableDetector->GetFoundTableRectangle_Left(&left); pITableDetector->GetFoundTableRectangle_Top(&top); pITableDetector->GetFoundTableRectangle_Width(&width); pITableDetector->GetFoundTableRectangle_Height(&height); // Set extraction area for CSV extractor to rectangle received from the table detector pICSVExtractor->SetExtractionArea(left, top, width, height); // Export the table to CSV file CString fileName; fileName.Format(L"page-%d-table-%d.csv", pageIndex, t); pICSVExtractor->SavePageCSVToFile(pageIndex, _bstr_t(fileName)); t++; pITableDetector->FindNextTable(&vbResult); } while (vbResult == VARIANT_TRUE); } } pICSVExtractor->Release(); pITableDetector->Release(); CoUninitialize(); return 0; }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

stdafx.cpp
      
// stdafx.cpp : source file that includes just the standard includes // CPPExample.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

stdafx.h
      
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include <stdio.h> #include <tchar.h> // TODO: reference additional headers your program requires here #include <atlstr.h>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

targetver.h
      
#pragma once // Including SDKDDKVer.h defines the highest available Windows platform. // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. #include <SDKDDKVer.h>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next