res == PXCV_Error.PS_ERR_DocEncrypted stating cannot compare an int to a constant out of range
I looked at the latest PXCView example and the password code is gone
Code: Select all
private bool OpenPDF()
{
int res = 0;
if (DialogResult.OK != openDlg.ShowDialog(this))
return false;
res = PXCV_Lib36.PXCV_Init(out m_Doc, "myCode", "mydev");
if (PXCV_Error.IS_DS_FAILED(res))
PXCV_Error.ShowDSErrorString(this, res);
res = PXCV_Lib36.PXCV_ReadDocumentW(m_Doc, openDlg.FileName, 0);
if (res == PXCV_Error.PS_ERR_DocEncrypted)
{
frmPassword dlgPassword = new frmPassword();
bool bCancel = false;
do
{
if (DialogResult.OK != dlgPassword.ShowDialog(this))
bCancel = true;
else
{
string password = dlgPassword.GetPassword();
byte[] bytepass = PXCV_Helper.StringToBytes(password);
res = PXCV_Lib36.PXCV_CheckPassword(m_Doc, bytepass, bytepass.Length);
if (PXCV_Error.IS_DS_FAILED(res))
break;
}
}
while (!bCancel);
if (PXCV_Error.IS_DS_SUCCESSFUL(res))
{
res = PXCV_Lib36.PXCV_FinishReadDocument(m_Doc, 0);
}
}
if (PXCV_Error.IS_DS_FAILED(res))
{
ClosePDF();
PXCV_Error.ShowDSErrorString(this, res);
return false;
}
return true;
}
but if I use this code I get it to work
Code: Select all
byte[] bytepass = PXCV_Helper.StringToBytes("myPwd");
res = PXCV_Lib36.PXCV_ReadDocumentW(m_Doc, openDlg.FileName, 0);
res = PXCV_Lib36.PXCV_CheckPassword(m_Doc, bytepass, bytepass.Length);
if (PXCV_Error.IS_DS_SUCCESSFUL(res))
{
res = PXCV_Lib36.PXCV_FinishReadDocument(m_Doc, 0); }