Convert PDF Files to Excel
The code below shows you how to convert a PDF file to an Excel spreadsheet.
using System; using System.IO; using SolidFramework.Converters.Plumbing; using SolidFramework.Converters; namespace PDFtoExcel { class Program { [STAThread] static void Main(string[] args) { // Call your Solid Documents License SolidFramework.License.Import(@"C:\MyFolder\license.xml"); // Set the location of your the file you want to convert String pdfPath = @"C:\YourFolder\filepdf.pdf"; // Set the file extension you are creating String xlsFile = Path.ChangeExtension(pdfPath, "xlsx"); //*PDF to XLSX*// using (PdfToExcelConverter converter = new PdfToExcelConverter()) { // Add files to convert. converter.AddSourceFile(pdfPath); // Set the preferred conversion properties // This combines all tables onto one sheet converter.SingleTable = ExcelTablesOnSheet.PlaceAllTablesOnSingleSheet; // This gets Non Table Content converter.TablesFromContent = true; // convert the file, calling it the same name but with a different extention , setting overwrite to true converter.ConvertTo(xlsFile, true); // Show the status of the PDF file in the Console Window SolidFramework.Converters.Plumbing.ConversionStatus status = converter.ConvertTo(xlsFile, true); if (status != ConversionStatus.Success) { Console.WriteLine(status); Console.ReadKey(); } } } } }
#include “stdafx.h”
#include “SolidFramework.h”
#include
using namespace std;
void DoProgress(SolidFramework::ProgressEventArgsPtr args)
{
// Not implemented
}
void DoWarning(SolidFramework::WarningEventArgsPtr args)
{
// Not implemented
}
class PdfToExcelConverter : public SolidFramework::Converters::PdfToExcelConverterBase
{
public:
void FireProgress(SolidFramework::ProgressEventArgsPtr args) override { DoProgress(args); };
void FireWarning(SolidFramework::WarningEventArgsPtr args) override { DoWarning(args); };
};
int _tmain(int argc, _TCHAR* argv[])
{
/*Enter your Solid Documents License Information Here*/
SolidFramework::License::Import(L”C:\\MyFolder\\license.xml”);
PdfToExcelConverter *converter = new PdfToExcelConverter();
SolidFramework::Converters::CustomData *pData = NULL;
pData = new SolidFramework::Converters::CustomData();
pData->Converter = converter;
pData->Data = nullptr;
converter->setCustomData(pData);
// Add files to convert and directory to output converted file
converter->AddSourceFile(L”C:\\YourFolder\\yourpdf.pdf”);
converter->setOutputDirectory(L”C:\\MyFolder”);
// Set the file extension you are creating
converter->setOutputType(SolidFramework::Converters::Plumbing::ExcelDocumentType::XlsX);
//This combines all tables onto one sheet
converter->setSingleTable(SolidFramework::Converters::Plumbing::ExcelTablesOnSheet::PlaceAllTablesOnSingleSheet);
// This gets Non Table Content
converter->setTablesFromContent(true);
// Convert the file
cout << "Starting conversion." << endl; converter->Convert();
SolidFramework::Converters::Plumbing::ConversionStatus status = converter->getResults()->getItem(0)->getStatus();
if (status != SolidFramework::Converters::Plumbing::ConversionStatus::Success)
{
cout << "Conversion failed." << endl;
}
else
{
cout << "Conversion succeeded." << endl; } converter->Dispose();
cout << "Press