Fix AddMetada and GetMetaData

This commit is contained in:
Svetlana Kulikova
2023-11-17 16:58:59 +03:00
parent 01c735bc71
commit 107377b905
9 changed files with 109 additions and 113 deletions

View File

@ -177,7 +177,6 @@ public:
CPdfReader* pReader; CPdfReader* pReader;
CPdfWriter* pWriter; CPdfWriter* pWriter;
PdfWriter::CStreamData* pMetaData;
LONG lClipMode; LONG lClipMode;
bool bEdit; bool bEdit;
bool bEditPage; bool bEditPage;
@ -261,7 +260,6 @@ CPdfFile::CPdfFile(NSFonts::IApplicationFonts* pAppFonts)
m_pInternal->pAppFonts = pAppFonts; m_pInternal->pAppFonts = pAppFonts;
m_pInternal->pWriter = NULL; m_pInternal->pWriter = NULL;
m_pInternal->pReader = NULL; m_pInternal->pReader = NULL;
m_pInternal->pMetaData = NULL;
m_pInternal->wsPassword = L""; m_pInternal->wsPassword = L"";
m_pInternal->bEdit = false; m_pInternal->bEdit = false;
m_pInternal->bEditPage = false; m_pInternal->bEditPage = false;
@ -270,8 +268,6 @@ CPdfFile::~CPdfFile()
{ {
RELEASEOBJECT(m_pInternal->pWriter); RELEASEOBJECT(m_pInternal->pWriter);
RELEASEOBJECT(m_pInternal->pReader); RELEASEOBJECT(m_pInternal->pReader);
if (m_pInternal->pMetaData && !m_pInternal->pMetaData->IsIndirect())
RELEASEOBJECT(m_pInternal->pMetaData);
} }
NSFonts::IFontManager* CPdfFile::GetFontManager() NSFonts::IFontManager* CPdfFile::GetFontManager()
{ {
@ -1071,7 +1067,7 @@ void CPdfFile::ToXml(const std::wstring& sFile, bool bSaveStreams)
m_pInternal->pReader->ToXml(sFile, bSaveStreams); m_pInternal->pReader->ToXml(sFile, bSaveStreams);
} }
bool CPdfFile::GetMetaData(const std::wstring& sFile, BYTE** pMetaData, DWORD& nMetaLength) bool CPdfFile::GetMetaData(const std::wstring& sFile, const std::wstring& sMetaName, BYTE** pMetaData, DWORD& nMetaLength)
{ {
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
if (!oFile.OpenFile(sFile)) if (!oFile.OpenFile(sFile))
@ -1109,107 +1105,53 @@ bool CPdfFile::GetMetaData(const std::wstring& sFile, BYTE** pMetaData, DWORD& n
RELEASEARRAYOBJECTS(pBuffer); RELEASEARRAYOBJECTS(pBuffer);
return false; return false;
} }
int nObjBegin = pFirst - (char*)pBuffer;
pFirst += 11; pFirst += 11;
pFirst = strstr(pFirst, "/Length "); std::string sMeta = U_TO_UTF8(sMetaName);
char* pStream = strstr(pFirst, "stream\015\012"); char* pStream = strstr(pFirst, "stream\015\012");
if (!pFirst || !pStream || pStream < pFirst) char* pMeta = strstr(pFirst, sMeta.c_str());
if (!pStream || !pMeta || pStream < pMeta)
{ {
RELEASEARRAYOBJECTS(pBuffer); RELEASEARRAYOBJECTS(pBuffer);
return false; return false;
} }
pFirst += 8;
pStream += 8; pStream += 8;
int nStreamBegin = pStream - (char*)pBuffer; int nStreamBegin = pStream - (char*)pBuffer;
pMeta += sMeta.length() + 3;
char* pLast = strstr(pFirst, " "); char* pMetaLast = strstr(pMeta, " ");
if (!pLast) if (!pMetaLast)
{ {
RELEASEARRAYOBJECTS(pBuffer); RELEASEARRAYOBJECTS(pBuffer);
return false; return false;
} }
std::string sMetaOffset = std::string(pMeta, pMetaLast - pMeta);
int nMetaOffset = std::stoi(sMetaOffset);
std::string sLength = std::string(pFirst, pLast - pFirst); pMeta = pMetaLast + 1;
int nStreamLength = std::stoi(sLength); pMetaLast = strstr(pMeta, " ");
RELEASEARRAYOBJECTS(pBuffer); if (!pMetaLast)
nBufferSize = nStreamBegin + nStreamLength + 20;
pBuffer = new BYTE[nBufferSize];
if (!pBuffer)
return false;
nReadBytes = 0;
if (!oFile.OpenFile(sFile) || !oFile.ReadFile(pBuffer, nBufferSize, nReadBytes))
{ {
RELEASEARRAYOBJECTS(pBuffer); RELEASEARRAYOBJECTS(pBuffer);
return false;
}
std::string sMetaSize = std::string(pMeta, pMetaLast - pMeta);
nMetaLength = std::stoi(sMetaSize);
RELEASEARRAYOBJECTS(pBuffer);
*pMetaData = new BYTE[nMetaLength];
pBuffer = *pMetaData;
nReadBytes = 0;
if (!oFile.OpenFile(sFile) || !oFile.SeekFile(nStreamBegin + nMetaOffset) || !oFile.ReadFile(pBuffer, nMetaLength, nReadBytes))
{
RELEASEARRAYOBJECTS(pBuffer);
pMetaData = NULL;
oFile.CloseFile(); oFile.CloseFile();
return false; return false;
} }
oFile.CloseFile(); oFile.CloseFile();
nMetaLength = nReadBytes;
Object oDictStream;
oDictStream.initNull();
BaseStream* str = new MemStream((char*)pBuffer, 0, nReadBytes, &oDictStream);
if (!str)
{
RELEASEARRAYOBJECTS(pBuffer);
return false;
}
Object oObj;
Parser* parser = new Parser(NULL, new Lexer(NULL, str->makeSubStream(str->getStart() + nObjBegin, gFalse, 0, &oObj)), gTrue);
if (!parser->getObj(&oObj, gTrue)->isInt())
{
RELEASEARRAYOBJECTS(pBuffer);
oObj.free();
return false;
}
oObj.free();
if (!parser->getObj(&oObj, gTrue)->isInt())
{
RELEASEARRAYOBJECTS(pBuffer);
oObj.free();
return false;
}
oObj.free();
if (!parser->getObj(&oObj, gTrue)->isCmd("obj"))
{
RELEASEARRAYOBJECTS(pBuffer);
oObj.free();
return false;
}
oObj.free();
if (!parser->getObj(&oObj)->isStream())
{
RELEASEARRAYOBJECTS(pBuffer);
oObj.free();
return false;
}
Stream* sData = oObj.getStream();
Dict* dict = sData->getDict();
Object oLength;
if (dict->lookup("Length", &oLength)->isInt())
{
nMetaLength = oLength.getInt();
Stream* pImage = sData->getUndecodedStream();
pImage->reset();
*pMetaData = new BYTE[nMetaLength];
BYTE* pBufferPtr = *pMetaData;
for (int nI = 0; nI < nMetaLength; ++nI)
*pBufferPtr++ = (BYTE)pImage->getChar();
}
oLength.free();
oObj.free();
delete parser;
RELEASEARRAYOBJECTS(pBuffer);
RELEASEOBJECT(str);
return true; return true;
} }
bool CPdfFile::LoadFromFile(const std::wstring& file, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password) bool CPdfFile::LoadFromFile(const std::wstring& file, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password)
@ -1389,7 +1331,7 @@ BYTE* CPdfFile::GetAPAnnots(int nRasterW, int nRasterH, int nBackgroundColor, in
void CPdfFile::CreatePdf(bool isPDFA) void CPdfFile::CreatePdf(bool isPDFA)
{ {
RELEASEOBJECT(m_pInternal->pWriter); RELEASEOBJECT(m_pInternal->pWriter);
m_pInternal->pWriter = new CPdfWriter(m_pInternal->pAppFonts, isPDFA, this, m_pInternal->pMetaData); m_pInternal->pWriter = new CPdfWriter(m_pInternal->pAppFonts, isPDFA, this);
} }
int CPdfFile::SaveToFile(const std::wstring& wsPath) int CPdfFile::SaveToFile(const std::wstring& wsPath)
{ {
@ -1409,14 +1351,11 @@ void CPdfFile::SetDocumentID(const std::wstring& wsDocumentID)
return; return;
m_pInternal->pWriter->SetDocumentID(wsDocumentID); m_pInternal->pWriter->SetDocumentID(wsDocumentID);
} }
bool CPdfFile::SetMetaData(BYTE* pMetaData, DWORD nMetaLength) void CPdfFile::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
{ {
if (m_pInternal->pWriter) if (!m_pInternal->pWriter)
return false; return;
m_pInternal->pWriter->AddMetaData(sMetaName, pMetaData, nMetaLength);
RELEASEOBJECT(m_pInternal->pMetaData);
m_pInternal->pMetaData = new PdfWriter::CStreamData(pMetaData, nMetaLength);
return true;
} }
HRESULT CPdfFile::OnlineWordToPdf(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams) HRESULT CPdfFile::OnlineWordToPdf(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams)
{ {

View File

@ -110,7 +110,7 @@ public:
void SetCMapFile(const std::wstring& sFile); void SetCMapFile(const std::wstring& sFile);
void ToXml(const std::wstring& sFile, bool bSaveStreams = false); void ToXml(const std::wstring& sFile, bool bSaveStreams = false);
bool GetMetaData(const std::wstring& sFile, BYTE** pMetaData, DWORD& nMetaLength); bool GetMetaData(const std::wstring& sFile, const std::wstring& sMetaName, BYTE** pMetaData, DWORD& nMetaLength);
virtual bool LoadFromFile (const std::wstring& file, const std::wstring& options = L"", const std::wstring& owner_password = L"", const std::wstring& user_password = L""); virtual bool LoadFromFile (const std::wstring& file, const std::wstring& options = L"", const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
virtual bool LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options = L"", const std::wstring& owner_password = L"", const std::wstring& user_password = L""); virtual bool LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options = L"", const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
virtual NSFonts::IApplicationFonts* GetFonts(); virtual NSFonts::IApplicationFonts* GetFonts();
@ -144,7 +144,7 @@ public:
void SetDocumentID(const std::wstring& wsDocumentID); void SetDocumentID(const std::wstring& wsDocumentID);
void Sign(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsPicturePath, ICertificate* pCertificate); void Sign(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsPicturePath, ICertificate* pCertificate);
void SetDocumentInfo(const std::wstring& wsTitle, const std::wstring& wsCreator, const std::wstring& wsSubject, const std::wstring& wsKeywords); void SetDocumentInfo(const std::wstring& wsTitle, const std::wstring& wsCreator, const std::wstring& wsSubject, const std::wstring& wsKeywords);
bool SetMetaData(BYTE* pMetaData, DWORD nMetaLength); void AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength);
HRESULT OnlineWordToPdf (const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams = NULL); HRESULT OnlineWordToPdf (const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams = NULL);
HRESULT OnlineWordToPdfFromBinary(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams = NULL); HRESULT OnlineWordToPdfFromBinary(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams = NULL);

View File

@ -95,7 +95,7 @@ static const long c_BrushTypeRadialGradient = 8002;
// CPdfRenderer // CPdfRenderer
// //
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
CPdfWriter::CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA, IRenderer* pRenderer, PdfWriter::CStreamData* pMetaData) : m_oCommandManager(this) CPdfWriter::CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA, IRenderer* pRenderer) : m_oCommandManager(this)
{ {
// Создаем менеджер шрифтов с собственным кэшем // Создаем менеджер шрифтов с собственным кэшем
m_pFontManager = pAppFonts->GenerateFontManager(); m_pFontManager = pAppFonts->GenerateFontManager();
@ -109,7 +109,7 @@ CPdfWriter::CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA, IRend
if (isPDFA) if (isPDFA)
m_pDocument->SetPDFAConformanceMode(true); m_pDocument->SetPDFAConformanceMode(true);
if (!m_pDocument || !m_pDocument->CreateNew(pMetaData)) if (!m_pDocument || !m_pDocument->CreateNew())
{ {
SetError(); SetError();
return; return;
@ -2327,6 +2327,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
return S_OK; return S_OK;
} }
HRESULT CPdfWriter::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
{
return m_pDocument->AddMetaData(sMetaName, pMetaData, nMetaLength) ? S_OK : S_FALSE;
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Дополнительные функции Pdf рендерера // Дополнительные функции Pdf рендерера
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ namespace Aggplus
class CPdfWriter class CPdfWriter
{ {
public: public:
CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA = false, IRenderer* pRenderer = NULL, PdfWriter::CStreamData* pMetaData = NULL); CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA = false, IRenderer* pRenderer = NULL);
~CPdfWriter(); ~CPdfWriter();
int SaveToFile(const std::wstring& wsPath); int SaveToFile(const std::wstring& wsPath);
void SetPassword(const std::wstring& wsPassword); void SetPassword(const std::wstring& wsPassword);
@ -196,6 +196,7 @@ public:
HRESULT AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage); HRESULT AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage);
HRESULT AddFormField (NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo, const std::wstring& wsTempDirectory); HRESULT AddFormField (NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo, const std::wstring& wsTempDirectory);
HRESULT AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotFieldInfo* pFieldInfo); HRESULT AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotFieldInfo* pFieldInfo);
HRESULT AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength);
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Дополнительные функции Pdf рендерера // Дополнительные функции Pdf рендерера
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------

View File

@ -103,7 +103,7 @@ namespace PdfWriter
{ {
Close(); Close();
} }
bool CDocument::CreateNew(CStreamData* pMetaData) bool CDocument::CreateNew()
{ {
Close(); Close();
@ -115,8 +115,9 @@ namespace PdfWriter
if (!m_pTrailer) if (!m_pTrailer)
return false; return false;
if (pMetaData) m_pMetaData = new CStreamData(m_pXref);
m_pXref->Add(pMetaData); if (!m_pMetaData)
return false;
m_pCatalog = new CCatalog(m_pXref); m_pCatalog = new CCatalog(m_pXref);
if (!m_pCatalog) if (!m_pCatalog)
@ -405,7 +406,13 @@ namespace PdfWriter
m_pCatalog->AddPageLabel(unPageNum, pPageLabel); m_pCatalog->AddPageLabel(unPageNum, pPageLabel);
} }
CDictObject* CDocument::CreatePageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix) bool CDocument::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
{
if (!m_pMetaData)
return false;
return m_pMetaData->AddMetaData(sMetaName, pMetaData, nMetaLength);
}
CDictObject* CDocument::CreatePageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
{ {
CDictObject* pLabel = new CDictObject(); CDictObject* pLabel = new CDictObject();
if (!pLabel) if (!pLabel)

View File

@ -101,7 +101,7 @@ namespace PdfWriter
CDocument(); CDocument();
~CDocument(); ~CDocument();
bool CreateNew(CStreamData* pMetaData = NULL); bool CreateNew();
void Close(); void Close();
bool SaveToFile(const std::wstring& wsPath, bool bAdd = true); bool SaveToFile(const std::wstring& wsPath, bool bAdd = true);
@ -126,6 +126,7 @@ namespace PdfWriter
void AddPageLabel(unsigned int unPageIndex, EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix); void AddPageLabel(unsigned int unPageIndex, EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix);
COutline* CreateOutline(COutline* pParent, const char* sTitle); COutline* CreateOutline(COutline* pParent, const char* sTitle);
CDestination* CreateDestination(unsigned int unPageIndex); CDestination* CreateDestination(unsigned int unPageIndex);
bool AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength);
CExtGrState* GetExtGState(double dAlphaStroke = -1, double dAlphaFill = -1, EBlendMode eMode = blendmode_Unknown, int nStrokeAdjustment = -1); CExtGrState* GetExtGState(double dAlphaStroke = -1, double dAlphaFill = -1, EBlendMode eMode = blendmode_Unknown, int nStrokeAdjustment = -1);
CExtGrState* GetStrokeAlpha(double dAlpha); CExtGrState* GetStrokeAlpha(double dAlpha);
@ -248,6 +249,7 @@ namespace PdfWriter
CInfoDict* m_pInfo; CInfoDict* m_pInfo;
CDictObject* m_pTrailer; CDictObject* m_pTrailer;
CDictObject* m_pResources; CDictObject* m_pResources;
CStreamData* m_pMetaData;
bool m_bEncrypt; bool m_bEncrypt;
CEncryptDict* m_pEncryptDict; CEncryptDict* m_pEncryptDict;
std::vector<TSignatureInfo> m_vSignatures; std::vector<TSignatureInfo> m_vSignatures;

View File

@ -167,16 +167,38 @@ namespace PdfWriter
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// StreamData // StreamData
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
CStreamData::CStreamData(BYTE* pMetaData, DWORD nMetaLength) CStreamData::CStreamData(CXref* pXref)
{ {
CMemoryStream* pStream = new CMemoryStream(); pXref->Add(this);
pStream->Write(pMetaData, nMetaLength);
m_pStream = new CMemoryStream();
Add("Length", 1234567890); Add("Length", 1234567890);
SetStream(NULL, pStream); Add("Type", "MetaOForm");
SetStream(pXref, m_pStream);
m_nLengthBegin = 0; m_nLengthBegin = 0;
m_nLengthEnd = 0; m_nLengthEnd = 0;
} }
bool CStreamData::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
{
if (sMetaName == L"Length")
return false;
CArrayObject* pArr = new CArrayObject();
if (!pArr)
return false;
std::string sKey = U_TO_UTF8(sMetaName);
Add(sKey, pArr);
//m_pStream1->WriteChar('\012');
int nCur = m_pStream->Tell();
pArr->Add(nCur);
pArr->Add((int)nMetaLength);
m_pStream->Write(pMetaData, nMetaLength);
return true;
}
void CStreamData::WriteToStream(CStream* pStream, CEncrypt* pEncrypt) void CStreamData::WriteToStream(CStream* pStream, CEncrypt* pEncrypt)
{ {
for (auto const &oIter : m_mList) for (auto const &oIter : m_mList)

View File

@ -56,16 +56,19 @@ namespace PdfWriter
class CStreamData : public CDictObject class CStreamData : public CDictObject
{ {
public: public:
CStreamData(BYTE* pMetaData, DWORD nMetaLength); CStreamData(CXref* pXref);
EDictType GetDictType() const override EDictType GetDictType() const override
{ {
return dict_type_STREAM; return dict_type_STREAM;
} }
bool AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength);
void WriteToStream(CStream* pStream, CEncrypt* pEncrypt) override; void WriteToStream(CStream* pStream, CEncrypt* pEncrypt) override;
void AfterWrite(CStream* pStream) override; void AfterWrite(CStream* pStream) override;
private: private:
CMemoryStream* m_pStream;
int m_nLengthBegin; int m_nLengthBegin;
int m_nLengthEnd; int m_nLengthEnd;
}; };

View File

@ -144,14 +144,26 @@ std::wstring CPdfFileTest::wsTempDir;
TEST_F(CPdfFileTest, GetMetaData) TEST_F(CPdfFileTest, GetMetaData)
{ {
GTEST_SKIP(); // GTEST_SKIP();
BYTE* pMetaData = NULL; BYTE* pMetaData = NULL;
DWORD nMetaLength = 0; DWORD nMetaLength = 0;
if (pdfFile->GetMetaData(wsSrcFile, &pMetaData, nMetaLength))
if (pdfFile->GetMetaData(wsSrcFile, L"Test0", &pMetaData, nMetaLength))
{ {
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/resGetMetaData.png")) if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/resGetMetaData0.png"))
oFile.WriteFile(pMetaData, nMetaLength);
oFile.CloseFile();
EXPECT_TRUE(pMetaData);
}
RELEASEARRAYOBJECTS(pMetaData);
if (pdfFile->GetMetaData(wsSrcFile, L"Test1", &pMetaData, nMetaLength))
{
NSFile::CFileBinary oFile;
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/resGetMetaData1.png"))
oFile.WriteFile(pMetaData, nMetaLength); oFile.WriteFile(pMetaData, nMetaLength);
oFile.CloseFile(); oFile.CloseFile();
@ -197,16 +209,22 @@ TEST_F(CPdfFileTest, PdfFromBin)
TEST_F(CPdfFileTest, SetMetaData) TEST_F(CPdfFileTest, SetMetaData)
{ {
GTEST_SKIP(); //GTEST_SKIP();
pdfFile->CreatePdf();
BYTE* pFileData = NULL; BYTE* pFileData = NULL;
DWORD nFileSize; DWORD nFileSize;
std::wstring sFile = NSFile::GetProcessDirectory() + L"/res0.png"; std::wstring sFile = NSFile::GetProcessDirectory() + L"/res0.png";
EXPECT_TRUE(NSFile::CFileBinary::ReadAllBytes(sFile, &pFileData, nFileSize)); EXPECT_TRUE(NSFile::CFileBinary::ReadAllBytes(sFile, &pFileData, nFileSize));
pdfFile->SetMetaData(pFileData, nFileSize); pdfFile->AddMetaData(L"Test0", pFileData, nFileSize);
RELEASEARRAYOBJECTS(pFileData);
sFile = NSFile::GetProcessDirectory() + L"/res1.png";
EXPECT_TRUE(NSFile::CFileBinary::ReadAllBytes(sFile, &pFileData, nFileSize));
pdfFile->AddMetaData(L"Test1", pFileData, nFileSize);
RELEASEARRAYOBJECTS(pFileData); RELEASEARRAYOBJECTS(pFileData);
pdfFile->CreatePdf();
EXPECT_HRESULT_SUCCEEDED(pdfFile->OnlineWordToPdfFromBinary(NSFile::GetProcessDirectory() + L"/pdf.bin", wsDstFile)); EXPECT_HRESULT_SUCCEEDED(pdfFile->OnlineWordToPdfFromBinary(NSFile::GetProcessDirectory() + L"/pdf.bin", wsDstFile));
} }