Encrypted PDF
Encrypted PDF
Where can I get a demonstration code to generate encripted pdf's in c++ using the CDINTF.DLL api?
Hello,
You can obtain a demo version of the PDF Converter Professional edition from the link below.
http://www.amyuni.com/en/products/pdf_c ... /demo.html
Once you have installed the product, please look at the install.ini file which is in the directory where you extracted the PDF Converter installation files. This ini file also contains the information you will need.
Thanks
You can obtain a demo version of the PDF Converter Professional edition from the link below.
http://www.amyuni.com/en/products/pdf_c ... /demo.html
Once you have installed the product, please look at the install.ini file which is in the directory where you extracted the PDF Converter installation files. This ini file also contains the information you will need.
Thanks
Hello Jose,
thanks for your reply, but in the install.ini the only thing I have is :
[Default]
PrinterName="Amyuni PDF Converter"
Licensee="Evaluation Version Developer Pro"
LicCode="07EFCDAB010001001A62D63AAE364ADFD58E5C771E417CBC1622CE145AA431E6CCCF852963C57AE96ECB09167E3050FEC9FA4879FFEB40E4087C394B8B5FB0A19A8C3A1F5877F8DC2876FA965C7E3593F42639234E76372F9D0BCC451E3EC35A34CD77"
What I nead is some C++ demonstration code to generate encripted pdf's file using the CDINTF.DLL api.
¿Is that possible?
thanks for your reply, but in the install.ini the only thing I have is :
[Default]
PrinterName="Amyuni PDF Converter"
Licensee="Evaluation Version Developer Pro"
LicCode="07EFCDAB010001001A62D63AAE364ADFD58E5C771E417CBC1622CE145AA431E6CCCF852963C57AE96ECB09167E3050FEC9FA4879FFEB40E4087C394B8B5FB0A19A8C3A1F5877F8DC2876FA965C7E3593F42639234E76372F9D0BCC451E3EC35A34CD77"
What I nead is some C++ demonstration code to generate encripted pdf's file using the CDINTF.DLL api.
¿Is that possible?
Hello,
Below is a code snippet that uses the encrypt function of the PDF Converter. Hope this helps.
//Button on dialog is called Open File
void CCDIntfDocDlg::OnButtonEncrypt()
{
CString strFilename, strOwnerPass, strUserPass;
DWORD dwPerms;
m_sFilename.GetWindowText(strFilename);
m_edtOwnerPass.GetWindowText(strOwnerPass);
m_edtUserPass.GetWindowText(strUserPass);
dwPerms = -64;
if (m_btnChange.GetCheck())
dwPerms |= SECURITY_CHANGE;
if (m_btnPrint.GetCheck())
dwPerms |= SECURITY_PRINT;
if (m_btnCopy.GetCheck())
dwPerms |= SECURITY_CUTCOPY;
if (m_btnAdd.GetCheck())
dwPerms |= SECURITY_FORMS;
_bstr_t bstrFilename(strFilename);
_bstr_t bstrOwnerPass(strOwnerPass);
_bstr_t bstrUserPass(strUserPass);
CDIntfEx::IDIDocumentPtr pDocument(__uuidof(CDIntfEx::Document));
pDocument->SetLicenseKey("Evaluation Version", "07EFCDAB01000100C71720CBEF064821466D5694417DB50143E40D4A14E5D47EF707562F287274F4AA099D562E4F6DC6F5CF1F74904B9BFE995AC248306749C9092EA202478B0E1D72748B5D78870EC242CC8B9A4ABF6AA49DDF7E8AA44A6575449D");
try
{
pDocument->Open(bstrFilename);
}
catch(CException* e)
{
char szCause[255];
e->GetErrorMessage(szCause, 255 );
MessageBox(szCause,NULL,MB_OK);
e->Delete();
}
pDocument->Encrypt(bstrOwnerPass, bstrUserPass, dwPerms);
pDocument->Save(bstrFilename);
}
Thanks
Below is a code snippet that uses the encrypt function of the PDF Converter. Hope this helps.
//Button on dialog is called Open File
void CCDIntfDocDlg::OnButtonEncrypt()
{
CString strFilename, strOwnerPass, strUserPass;
DWORD dwPerms;
m_sFilename.GetWindowText(strFilename);
m_edtOwnerPass.GetWindowText(strOwnerPass);
m_edtUserPass.GetWindowText(strUserPass);
dwPerms = -64;
if (m_btnChange.GetCheck())
dwPerms |= SECURITY_CHANGE;
if (m_btnPrint.GetCheck())
dwPerms |= SECURITY_PRINT;
if (m_btnCopy.GetCheck())
dwPerms |= SECURITY_CUTCOPY;
if (m_btnAdd.GetCheck())
dwPerms |= SECURITY_FORMS;
_bstr_t bstrFilename(strFilename);
_bstr_t bstrOwnerPass(strOwnerPass);
_bstr_t bstrUserPass(strUserPass);
CDIntfEx::IDIDocumentPtr pDocument(__uuidof(CDIntfEx::Document));
pDocument->SetLicenseKey("Evaluation Version", "07EFCDAB01000100C71720CBEF064821466D5694417DB50143E40D4A14E5D47EF707562F287274F4AA099D562E4F6DC6F5CF1F74904B9BFE995AC248306749C9092EA202478B0E1D72748B5D78870EC242CC8B9A4ABF6AA49DDF7E8AA44A6575449D");
try
{
pDocument->Open(bstrFilename);
}
catch(CException* e)
{
char szCause[255];
e->GetErrorMessage(szCause, 255 );
MessageBox(szCause,NULL,MB_OK);
e->Delete();
}
pDocument->Encrypt(bstrOwnerPass, bstrUserPass, dwPerms);
pDocument->Save(bstrFilename);
}
Thanks
Jose,
How can I get a CDC (hdc) from de document, or how can I set this properties to de CDC (hdc).
In a previous version of Amyuni I use :
HINSTANCE hLib = LoadLibrary("pdfintf.dll");
if (hLib != NULL)
{
SetDefaultFileNameProc SetDefaultFileName = NULL;
SetFileNameOptionProc SetFileNameOption = NULL;
SetDefaultFileName = (SetDefaultFileNameProc) GetProcAddress(hLib,"SetDefaultFileName");
SetFileNameOption = (SetFileNameOptionProc) GetProcAddress(hLib,"SetFileNameOptions");
if (SetDefaultFileName && SetFileNameOption)
{
(*SetDefaultFileName) (m_szPrintDevice,lpszOutput);
short nOptions = NoPrompt+UseFileName;
(*SetFileNameOption)(m_szPrintDevice,nOptions);
}
FreeLibrary(hLib);
}
¿Is this code still working?
¿how can I set de Encript Options using the pdfintf.dll?
How can I get a CDC (hdc) from de document, or how can I set this properties to de CDC (hdc).
In a previous version of Amyuni I use :
HINSTANCE hLib = LoadLibrary("pdfintf.dll");
if (hLib != NULL)
{
SetDefaultFileNameProc SetDefaultFileName = NULL;
SetFileNameOptionProc SetFileNameOption = NULL;
SetDefaultFileName = (SetDefaultFileNameProc) GetProcAddress(hLib,"SetDefaultFileName");
SetFileNameOption = (SetFileNameOptionProc) GetProcAddress(hLib,"SetFileNameOptions");
if (SetDefaultFileName && SetFileNameOption)
{
(*SetDefaultFileName) (m_szPrintDevice,lpszOutput);
short nOptions = NoPrompt+UseFileName;
(*SetFileNameOption)(m_szPrintDevice,nOptions);
}
FreeLibrary(hLib);
}
¿Is this code still working?
¿how can I set de Encript Options using the pdfintf.dll?
Hello,
PDFIntf.dll is a very old dll, you need to use CDintf210.dll instead with version 2.10 of the driver.
You can download CDintf210.dll and CDIntf210.h from: http://www.amyuni.com/downloads/cdintf210.zip
Hope this helps.
PDFIntf.dll is a very old dll, you need to use CDintf210.dll instead with version 2.10 of the driver.
You can download CDintf210.dll and CDIntf210.h from: http://www.amyuni.com/downloads/cdintf210.zip
Hope this helps.
Hello,
Below is a snippet of code that illustrates how to encrypt an existing PDF document. You can also get addition information by looking at the "Common Driver Interface210.pdf" that is shipped with the product.
void CPDFConverterView::OnPdfstuffEncrypt()
{
typedef BOOL (CALLBACK *lpfnSetLicenseKeyA)(LPCSTR Company, LPCSTR LicKey);
typedef BOOL (CALLBACK *lpEncryptPDFDocument)(LPCSTR FileName, LPCSTR Owner, LPCSTR User, DWORD Permissions);
lpEncryptPDFDocument EncryptPDFDocument;
lpfnSetLicenseKeyA SetLicenseKey;
HINSTANCE hModule = LoadLibrary( _T("CDINTF210.DLL") );
//if ( NULL == hModule )
//{
//return FALSE;
//}
SetLicenseKey = (lpfnSetLicenseKeyA)GetProcAddress( hModule, _T("SetLicenseKeyA") );
ASSERT( SetLicenseKey != NULL );
EncryptPDFDocument = (lpEncryptPDFDocument)GetProcAddress( hModule, _T("EncryptPDFDocument") );
ASSERT( EncryptPDFDocument != NULL );
SetLicenseKey ("Evaluation Version Developer", " 07EFCDAB01000100584F82968EE5DB671BE2564605099CD0F9AEB6BDBA542926639B79ECC556F310DB8592F1C68BF146A4D4E86EB8C0E7824CE83E1E8DC2244459F2F7CA64FC6CF3CC969D0749DAF7E37EF1621AEBEBF2975B547D9307884306A12B411999E3BC3641C3593C ");
EncryptPDFDocument ("c:\\ sample.pdf", "owner", "", -46);
}
Hope this helps.
Below is a snippet of code that illustrates how to encrypt an existing PDF document. You can also get addition information by looking at the "Common Driver Interface210.pdf" that is shipped with the product.
void CPDFConverterView::OnPdfstuffEncrypt()
{
typedef BOOL (CALLBACK *lpfnSetLicenseKeyA)(LPCSTR Company, LPCSTR LicKey);
typedef BOOL (CALLBACK *lpEncryptPDFDocument)(LPCSTR FileName, LPCSTR Owner, LPCSTR User, DWORD Permissions);
lpEncryptPDFDocument EncryptPDFDocument;
lpfnSetLicenseKeyA SetLicenseKey;
HINSTANCE hModule = LoadLibrary( _T("CDINTF210.DLL") );
//if ( NULL == hModule )
//{
//return FALSE;
//}
SetLicenseKey = (lpfnSetLicenseKeyA)GetProcAddress( hModule, _T("SetLicenseKeyA") );
ASSERT( SetLicenseKey != NULL );
EncryptPDFDocument = (lpEncryptPDFDocument)GetProcAddress( hModule, _T("EncryptPDFDocument") );
ASSERT( EncryptPDFDocument != NULL );
SetLicenseKey ("Evaluation Version Developer", " 07EFCDAB01000100584F82968EE5DB671BE2564605099CD0F9AEB6BDBA542926639B79ECC556F310DB8592F1C68BF146A4D4E86EB8C0E7824CE83E1E8DC2244459F2F7CA64FC6CF3CC969D0749DAF7E37EF1621AEBEBF2975B547D9307884306A12B411999E3BC3641C3593C ");
EncryptPDFDocument ("c:\\ sample.pdf", "owner", "", -46);
}
Hope this helps.
Hello,
Below is an example of generating an encrypted 128bit PDF document at run-time.
Hope this helps?
void CPDFConverterDllDlg::OnBnClickedEncrypt()
{
HINSTANCE hDLL; // Handle to DLL
hDLL = LoadLibrary( _T("CDINTF210.DLL") );
if ( hDLL != NULL )
{
//Get exported functions
DriverInit = (lpfnDriverInitProc)GetProcAddress(hDLL, "DriverInit");
if (DriverInit == NULL)
{
// handle the error
FreeLibrary(hDLL);
//return SOME_ERROR_CODE;
}
//Must check return codes of all functions
DriverEnd = (lpfnDriverEndProc) GetProcAddress (hDLL, _T("DriverEnd"));
SetDefaultDirectory = (lpfnSetDefaultDirectoryProc) GetProcAddress (hDLL, _T("SetDefaultDirectory"));
SetDefaultFileName = (lpfnSetDefaultFileNameProc) GetProcAddress (hDLL, _T("SetDefaultFileName"));
SetDefaultPrinter = (lpfnSetDefaultPrinterProc) GetProcAddress (hDLL, _T("SetDefaultPrinter"));
RestoreDefaultPrinter = (lpfnRestoreDefaultPrinterProc) GetProcAddress (hDLL, _T("RestoreDefaultPrinter"));
EnablePrinter = (lpfnEnablePrinterProc) GetProcAddress (hDLL, _T("EnablePrinter"));
SetFileNameOptions = (lpfnSetFileNameOptionsProc) GetProcAddress (hDLL, _T("SetFileNameOptions"));
SetDefaultConfig = (lpfnSetDefaultConfigProc) GetProcAddress (hDLL, _T("SetDefaultConfig"));
/********** Encryption functions **********/
SetOwnerPassword = (lpfnSetOwnerPasswordProc) GetProcAddress (hDLL, _T("SetOwnerPassword"));
SetUserPassword = (lpfnSetUserPasswordProc) GetProcAddress (hDLL, _T("SetUserPassword"));
SetPermissions = (lpfnSetPermissionsProc) GetProcAddress (hDLL, _T("SetPermissions"));
}
if( NULL == (hPdfPrinter = (*DriverInit)(szPrinter)))
{
//system error
AfxMessageBox("DriverInit Failed");
}
(*SetDefaultDirectory)(hPdfPrinter, "c:\\temp");
(*SetDefaultFileName)(hPdfPrinter, "c:\\temp\\sample.pdf");
(*SetDefaultPrinter)(hPdfPrinter);
/********** Encryption functions **********/
(*SetOwnerPassword) (hPdfPrinter, "owner");
(*SetUserPassword) (hPdfPrinter, "user");
(*SetPermissions) (hPdfPrinter, -64);
(*SetDefaultConfig) (hPdfPrinter);
(*SetFileNameOptions)(hPdfPrinter, NoPrompt | UseFileName | EncryptDocument128);
(*EnablePrinter)(hPdfPrinter , "Suite Evaluation Developer Pro",
"07EFCDAB01000100004D402BD98DEE8F3F5FD15C4CB2F336DA8D53D98E391DB5CCC674EE34D6149B6C3F9C94E116C9E48105E9A1D23B016E0A8D1B0EA74C099D7F7E7191267CAF4C0F3DC059AA489B2D59B0E06CD2EDED13835380AE9E4242BE292CA67BBF8505F51012537CD61098");
//////////////////////////////////////////////////////////////////////////////////////////////////
// Print
HDC hDC = CreateDC(_T("WINSPOOL"), szPrinter, NULL, NULL);
if(hDC == NULL)
{
AfxMessageBox ("Error");
}
DOCINFO di;
::ZeroMemory (&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("Sample Test Doc");
StartDoc(hDC, &di);
StartPage(hDC);
TextOut(hDC, 200, 200, _T("Print Test"), lstrlen (_T("Print Test")));
EndPage(hDC);
EndDoc(hDC);
DeleteDC(hDC);
(*RestoreDefaultPrinter)(hPdfPrinter);
FreeLibrary(hDLL);
}
Thanks
Below is an example of generating an encrypted 128bit PDF document at run-time.
Hope this helps?
void CPDFConverterDllDlg::OnBnClickedEncrypt()
{
HINSTANCE hDLL; // Handle to DLL
hDLL = LoadLibrary( _T("CDINTF210.DLL") );
if ( hDLL != NULL )
{
//Get exported functions
DriverInit = (lpfnDriverInitProc)GetProcAddress(hDLL, "DriverInit");
if (DriverInit == NULL)
{
// handle the error
FreeLibrary(hDLL);
//return SOME_ERROR_CODE;
}
//Must check return codes of all functions
DriverEnd = (lpfnDriverEndProc) GetProcAddress (hDLL, _T("DriverEnd"));
SetDefaultDirectory = (lpfnSetDefaultDirectoryProc) GetProcAddress (hDLL, _T("SetDefaultDirectory"));
SetDefaultFileName = (lpfnSetDefaultFileNameProc) GetProcAddress (hDLL, _T("SetDefaultFileName"));
SetDefaultPrinter = (lpfnSetDefaultPrinterProc) GetProcAddress (hDLL, _T("SetDefaultPrinter"));
RestoreDefaultPrinter = (lpfnRestoreDefaultPrinterProc) GetProcAddress (hDLL, _T("RestoreDefaultPrinter"));
EnablePrinter = (lpfnEnablePrinterProc) GetProcAddress (hDLL, _T("EnablePrinter"));
SetFileNameOptions = (lpfnSetFileNameOptionsProc) GetProcAddress (hDLL, _T("SetFileNameOptions"));
SetDefaultConfig = (lpfnSetDefaultConfigProc) GetProcAddress (hDLL, _T("SetDefaultConfig"));
/********** Encryption functions **********/
SetOwnerPassword = (lpfnSetOwnerPasswordProc) GetProcAddress (hDLL, _T("SetOwnerPassword"));
SetUserPassword = (lpfnSetUserPasswordProc) GetProcAddress (hDLL, _T("SetUserPassword"));
SetPermissions = (lpfnSetPermissionsProc) GetProcAddress (hDLL, _T("SetPermissions"));
}
if( NULL == (hPdfPrinter = (*DriverInit)(szPrinter)))
{
//system error
AfxMessageBox("DriverInit Failed");
}
(*SetDefaultDirectory)(hPdfPrinter, "c:\\temp");
(*SetDefaultFileName)(hPdfPrinter, "c:\\temp\\sample.pdf");
(*SetDefaultPrinter)(hPdfPrinter);
/********** Encryption functions **********/
(*SetOwnerPassword) (hPdfPrinter, "owner");
(*SetUserPassword) (hPdfPrinter, "user");
(*SetPermissions) (hPdfPrinter, -64);
(*SetDefaultConfig) (hPdfPrinter);
(*SetFileNameOptions)(hPdfPrinter, NoPrompt | UseFileName | EncryptDocument128);
(*EnablePrinter)(hPdfPrinter , "Suite Evaluation Developer Pro",
"07EFCDAB01000100004D402BD98DEE8F3F5FD15C4CB2F336DA8D53D98E391DB5CCC674EE34D6149B6C3F9C94E116C9E48105E9A1D23B016E0A8D1B0EA74C099D7F7E7191267CAF4C0F3DC059AA489B2D59B0E06CD2EDED13835380AE9E4242BE292CA67BBF8505F51012537CD61098");
//////////////////////////////////////////////////////////////////////////////////////////////////
HDC hDC = CreateDC(_T("WINSPOOL"), szPrinter, NULL, NULL);
if(hDC == NULL)
{
AfxMessageBox ("Error");
}
DOCINFO di;
::ZeroMemory (&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("Sample Test Doc");
StartDoc(hDC, &di);
StartPage(hDC);
TextOut(hDC, 200, 200, _T("Print Test"), lstrlen (_T("Print Test")));
EndPage(hDC);
EndDoc(hDC);
DeleteDC(hDC);
(*RestoreDefaultPrinter)(hPdfPrinter);
FreeLibrary(hDLL);
}
Thanks