Skip to content

Instantly share code, notes, and snippets.

@terjehelgesen
Last active August 14, 2024 20:01
Show Gist options
  • Save terjehelgesen/a7425bab131f267a71fc074a6d3a1f91 to your computer and use it in GitHub Desktop.
Save terjehelgesen/a7425bab131f267a71fc074a6d3a1f91 to your computer and use it in GitHub Desktop.
Convert a PDF file to PDF/A standard using C++
int ConvertPDFtoPDFA( WCHAR *SerialNumber, WCHAR *InputFile, WCHAR *OutputFile, int ConformStandard, BSTR *bstrErrors)
{
//Declare Conform function
typedef int ( *SC_CONFORM_FILE)(WCHAR *SerialNumber, WCHAR *InputFileName, int ConformStandard, WCHAR *OutputFileName, BSTR *Errors);
//Load scConverter.dll
HINSTANCE hLib = LoadLibraryExW( L"scConverter.dll", nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if (!hLib) return -1;
//Get Conform function pointer
SC_CONFORM_FILE ConformFileFunc = (SC_CONFORM_FILE)GetProcAddress( hLib, "scPDFConform" );
//Call Conform function
int result = ConformFileFunc( SerialNumber, InputFile, ConformStandard, OutputFile, bstrErrors);
FreeLibrary( hLib );
return result;
}
@terjehelgesen
Copy link
Author

Sample usage:
BSTR bstrErrors = nullptr;
int returnvalue = ConvertPDFtoPDFA( L"", L"input.pdf", 6, L"output.pdf", &bstrErrors ); //Conform type 6 = PDF/A-4

@terjehelgesen
Copy link
Author

Take a look at the scConverter Documentation for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment