Convert Protected PDF Document to Excel (C++ CLR) - C++
PDF Extractor SDK sample in C++ demonstrating ‘Convert Protected PDF Document to Excel (C++ CLR)’
CPPCLRConsoleApplication.cpp
#include "stdafx.h"
//
// This example demonstrates how to provide password for protected PDF files.
//
using namespace System;
using Bytescout::PDFExtractor::XLSExtractor;
// `PasswordRequired` event handler
void OnPasswordRequired(System::Object ^sender, System::EventArgs ^e);
int main(array<System::String ^> ^args)
{
String^ input(".\\encrypted (password is 'password').pdf");
String^ output(".\\result.xls");
// Create XLSExtractor instance
XLSExtractor^ pExtractor = gcnew XLSExtractor("demo", "demo");
// Handle `PasswordRequired` event
pExtractor->PasswordRequired += gcnew System::EventHandler(&OnPasswordRequired);
// Load PDF document
pExtractor->LoadDocumentFromFile(input);
// Save Excel document
pExtractor->SaveToXLSFile(output);
delete pExtractor;
// Open the output document in default associated application (for demonstration)
Diagnostics::Process::Start(output);
return 0;
}
// `PasswordRequired` event handler
void OnPasswordRequired(System::Object ^sender, System::EventArgs ^e)
{
// Ask user for password and put it to `Password` property.
safe_cast<XLSExtractor^>(sender)->Password = "password";
}
Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc
stdafx.cpp
#include "stdafx.h"
stdafx.h
#pragma once
// TODO: reference additional headers your program requires here