mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Create ValidMetaData
This commit is contained in:
@ -1525,6 +1525,12 @@ int CPdfFile::GetMaxRefID()
|
||||
|
||||
return m_pInternal->pReader->GetMaxRefID();
|
||||
}
|
||||
bool CPdfFile::ValidMetaData()
|
||||
{
|
||||
if (!m_pInternal->pReader)
|
||||
return false;
|
||||
return m_pInternal->pReader->ValidMetaData();
|
||||
}
|
||||
void CPdfFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
{
|
||||
if (!m_pInternal->pReader)
|
||||
|
||||
@ -128,6 +128,7 @@ public:
|
||||
virtual std::wstring GetInfo();
|
||||
virtual BYTE* GetStructure();
|
||||
virtual BYTE* GetLinks(int nPageIndex);
|
||||
bool ValidMetaData();
|
||||
int GetRotate(int nPageIndex);
|
||||
int GetMaxRefID();
|
||||
BYTE* GetWidgets();
|
||||
|
||||
@ -461,6 +461,33 @@ int CPdfReader::GetMaxRefID()
|
||||
return 0;
|
||||
return m_pPDFDocument->getXRef()->getNumObjects();
|
||||
}
|
||||
bool CPdfReader::ValidMetaData()
|
||||
{
|
||||
if (!m_pPDFDocument)
|
||||
return false;
|
||||
|
||||
XRef* xref = m_pPDFDocument->getXRef();
|
||||
Object oMeta, oType, oID;
|
||||
if (!xref->fetch(1, 0, &oMeta)->isStream() || !oMeta.streamGetDict()->lookup("Type", &oType)->isName("MetaOForm") || !oMeta.streamGetDict()->lookup("ID", &oID)->isString())
|
||||
{
|
||||
oMeta.free(); oType.free(); oID.free();
|
||||
return false;
|
||||
}
|
||||
oMeta.free(); oType.free();
|
||||
|
||||
Object oTID, oID2;
|
||||
Object* pTrailerDict = xref->getTrailerDict();
|
||||
if (!pTrailerDict || !pTrailerDict->dictLookup("ID", &oTID)->isArray() || !oTID.arrayGet(1, &oID2)->isString())
|
||||
{
|
||||
oID.free(); oTID.free(); oID2.free();
|
||||
return false;
|
||||
}
|
||||
oTID.free();
|
||||
|
||||
bool bRes = oID2.getString()->cmp(oID.getString()) == 0;
|
||||
oID.free(); oID2.free();
|
||||
return bRes;
|
||||
}
|
||||
void CPdfReader::DrawPageOnRenderer(IRenderer* pRenderer, int _nPageIndex, bool* pbBreak)
|
||||
{
|
||||
if (m_pPDFDocument && pRenderer)
|
||||
|
||||
@ -61,6 +61,7 @@ public:
|
||||
int GetError();
|
||||
int GetRotate(int nPageIndex);
|
||||
int GetMaxRefID();
|
||||
bool ValidMetaData();
|
||||
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||
std::wstring GetInfo();
|
||||
|
||||
@ -161,6 +161,15 @@ TEST_F(CPdfFileTest, GetMetaData)
|
||||
RELEASEARRAYOBJECTS(pMetaData);
|
||||
}
|
||||
|
||||
TEST_F(CPdfFileTest, ValidMetaData)
|
||||
{
|
||||
GTEST_SKIP();
|
||||
|
||||
LoadFromFile();
|
||||
|
||||
std::cout << "ValidMetaData " << (pdfFile->ValidMetaData() ? "true" : "false") << std::endl;
|
||||
}
|
||||
|
||||
TEST_F(CPdfFileTest, PdfBinToPng)
|
||||
{
|
||||
GTEST_SKIP();
|
||||
|
||||
Reference in New Issue
Block a user