Create CheckOwnerPassword

This commit is contained in:
Svetlana Kulikova
2025-11-19 18:23:23 +03:00
parent 6df7a7e01e
commit 1e18352e77
9 changed files with 88 additions and 9 deletions

View File

@ -245,7 +245,12 @@ public:
return 0;
}
bool CheckOwnerPassword(const std::wstring& sPassword)
{
if (m_nType == 0)
return ((CPdfFile*)m_pFile)->CheckOwnerPassword(sPassword);
return true;
}
BYTE* GetInfo()
{
NSWasm::CData oRes;

View File

@ -145,6 +145,10 @@ CFile.prototype["isNeedPassword"] = function()
{
return this._isNeedPassword;
};
CFile.prototype["CheckOwnerPassword"] = function(password)
{
return this._CheckOwnerPassword(password);
};
CFile.prototype["SplitPages"] = function(arrOriginIndex, arrayBufferChanges)
{
let ptr = this._SplitPages(arrOriginIndex, arrayBufferChanges);

View File

@ -146,6 +146,13 @@ CFile.prototype._UndoRedact = function()
return g_native_drawing_file["UndoRedact"]();
};
CFile.prototype._CheckOwnerPassword = function(password)
{
if (!password)
password = "";
return g_native_drawing_file["CheckOwnerPassword"](password);
}
// FONTS
CFile.prototype._isNeedCMap = function()
{

View File

@ -96,6 +96,13 @@ WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
return -1;
return pFile->GetErrorCode();
}
WASM_EXPORT int CheckOwnerPassword(CDrawingFile* pFile, const char* password)
{
std::wstring sPassword = L"";
if (NULL != password)
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
return pFile->CheckOwnerPassword(sPassword) ? 1 : 0;
}
WASM_EXPORT void Close(CDrawingFile* pFile)
{
delete pFile;

View File

@ -1125,6 +1125,13 @@ int main(int argc, char* argv[])
}
}
// OWNER PASSWORD
if (true)
{
std::string sPassword = "";
std::cout << "CheckOwnerPassword " << CheckOwnerPassword(pGrFile, sPassword.c_str()) << std::endl;
}
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// REDACT
if (false)
@ -1230,7 +1237,7 @@ int main(int argc, char* argv[])
}
// GLYPHS
if (false && nPagesCount > 0)
if (true && nPagesCount > 0)
{
BYTE* pGlyphs = GetGlyphs(pGrFile, nTestPage);
nLength = READ_INT(pGlyphs);