mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 03:42:47 +08:00
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include "../htmlfile2.h"
|
|
#include "../../DesktopEditor/common/File.h"
|
|
#include "../../DesktopEditor/common/Directory.h"
|
|
#include "../../OfficeUtils/src/OfficeUtils.h"
|
|
|
|
int main()
|
|
{
|
|
bool bBatchMode = false;
|
|
CHtmlFile2 oFile;
|
|
|
|
// Директория, где будем создавать docx
|
|
std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res";
|
|
NSDirectory::DeleteDirectory(sOutputDirectory);
|
|
NSDirectory::CreateDirectory(sOutputDirectory);
|
|
|
|
oFile.SetTmpDirectory(sOutputDirectory);
|
|
HRESULT nResConvert = S_FALSE;
|
|
|
|
CHtmlParams oParams;
|
|
oParams.AddAuthor(L"last first middle");
|
|
oParams.AddAuthor(L"last2 first2 middle2");
|
|
oParams.AddGenre(L"fantazy");
|
|
oParams.AddGenre(L"drama");
|
|
oParams.SetTitle(L"The Last Wish");
|
|
|
|
if(bBatchMode)
|
|
{
|
|
std::vector<std::wstring> arrFiles{NSFile::GetProcessDirectory() + L"/../../../examples/test1.html",
|
|
NSFile::GetProcessDirectory() + L"/../../../examples/test2.xhtml",
|
|
NSFile::GetProcessDirectory() + L"/../../../examples/test3.xhtml",
|
|
NSFile::GetProcessDirectory() + L"/../../../examples/test4.xhtml"};
|
|
nResConvert = oFile.OpenBatch(arrFiles, sOutputDirectory, &oParams);
|
|
}
|
|
else
|
|
{
|
|
// Файл, который открываем
|
|
std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test4.xhtml";
|
|
nResConvert = oFile.Open(sFile, sOutputDirectory, &oParams);
|
|
|
|
}
|
|
if(nResConvert == S_OK)
|
|
{
|
|
std::cout << "Success" << std::endl;
|
|
COfficeUtils oZip;
|
|
oZip.CompressFileOrDirectory(sOutputDirectory, sOutputDirectory + L"/Aggregate.docx");
|
|
}
|
|
else
|
|
std::cout << "Failure" << std::endl;
|
|
|
|
std::cout << "THE END" << std::endl;
|
|
return 0;
|
|
}
|