Commit 608c5df9 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Сделана специальная конвертация Djvu в Pdf, при которой ч/б картинки и...

Сделана специальная конвертация Djvu в Pdf, при которой ч/б картинки и составные картинки передаются через специальные функции для достижения лучшей скорости и лучшего финального размера pdf-файла.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63314 954022d7-b5bf-4e40-9824-e11837661b57
parent 1c720f92
......@@ -76,3 +76,14 @@ ASCOfficePPTXFile/PPTXFormat/!_
ASCOfficePPTXFile/PPTXFormat/_
ASCOfficePPTXFile/Release
DesktopEditor/build
DjVuFile/Debug
DjVuFile/DjVuFile.pro.user
DjVuFile/DjVuFile.sdf
DjVuFile/DjVuFile.vcxproj.filters
DjVuFile/DjVuFile.vcxproj.user
DjVuFile/DjVuFileTest/Debug
DjVuFile/DjVuFileTest/DjVuFileTest.vcxproj.filters
DjVuFile/DjVuFileTest/DjVuFileTest.vcxproj.user
DjVuFile/DjVuFileTest/x64
DjVuFile/ipch
DjVuFile/x64
......@@ -57,3 +57,8 @@ void CDjVuFile::ConvertToRaster(CApplicationFonts* pAppFonts, int
if (m_pImplementation)
m_pImplementation->ConvertToRaster(pAppFonts, nPageIndex, wsDstPath, nImageType);
}
void CDjVuFile::ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath)
{
if (m_pImplementation)
m_pImplementation->ConvertToPdf(pAppFonts, wsDstPath);
}
......@@ -27,4 +27,5 @@ public:
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
void ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType);
void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath);
};
\ No newline at end of file
......@@ -42,7 +42,8 @@ Global
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|Mixed Platforms.Build.0 = Release|Win32
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|Win32.ActiveCfg = Release|Win32
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|Win32.Build.0 = Release|Win32
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|x64.ActiveCfg = Release|Win32
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|x64.ActiveCfg = Release|x64
{6D3BC8A8-93A8-468E-90CE-BCEAC28B8788}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -90,7 +90,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;HAVE_NAMESPACES</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
<AdditionalIncludeDirectories>D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\freetype-2.5.2\include;D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\agg-2.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;..\..\ServerComponents\DesktopEditor\freetype-2.5.2\include;..\..\ServerComponents\DesktopEditor\agg-2.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......@@ -126,7 +126,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;HAVE_NAMESPACES</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4267;</DisableSpecificWarnings>
<AdditionalIncludeDirectories>D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;..\..\ServerComponents\DesktopEditor\freetype-2.5.2\include;..\..\ServerComponents\DesktopEditor\agg-2.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......
This diff is collapsed.
......@@ -9,6 +9,7 @@
#include "libdjvu/DataPool.h"
#include "libdjvu/DjVuText.h"
#include "libdjvu/DjVmNav.h"
#include "libdjvu/IW44Image.h"
#define ZIP_NO_COMPRESSION 0
#define ZIP_BEST_SPEED 1
......@@ -45,13 +46,15 @@ public:
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
void ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType);
void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath);
private:
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& text);
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
void CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
void CreateGrFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, bool* pBreak);
XmlUtils::CXmlNode ParseText(GP<DjVuImage> pPage);
void TextToRenderer(IRenderer* pRenderer, XmlUtils::CXmlNode text, double koef, bool isView = true);
void DrawText(IRenderer* pRenderer, double* pdCoords, const std::wstring& wsText);
void DrawPageText(IRenderer* pRenderer, double* pdCoords, const std::wstring& wsText);
void ParseCoords(const std::wstring& wsCoordsStr, double* pdCoords, double dKoef);
};
......@@ -8,7 +8,10 @@
#include <string>
#include "windows.h"
#include "../../DesktopEditor/common/String.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include <ctime>
#include <iostream>
std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstring wsExt)
{
......@@ -33,7 +36,7 @@ std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstrin
}
return vwsNames;
}
void ConvertFolder(CDjVuFile& oReader, std::wstring wsFolderPath)
void ConvertFolderToRaster(CDjVuFile& oReader, std::wstring wsFolderPath)
{
CApplicationFonts oFonts;
oFonts.Initialize();
......@@ -64,9 +67,41 @@ void ConvertFolder(CDjVuFile& oReader, std::wstring wsFolderPath)
}
}
}
void ConvertFolderToPdf(CDjVuFile& oReader, std::wstring wsFolderPath)
{
CApplicationFonts oFonts;
oFonts.Initialize();
oReader.Close();
clock_t oBeginTime = clock();
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, L"djvu");
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
{
std::wstring wsFilePath = wsFolderPath;
wsFilePath.append(vFiles.at(nIndex));
std::wstring wsFilePathName = (wsFilePath.substr(0, wsFilePath.size() - 5));
if (oReader.LoadFromFile(wsFilePath.c_str()))
{
std::wstring wsDstFilePath = wsFilePathName + L".pdf";
oReader.ConvertToPdf(&oFonts, wsDstFilePath);
printf("%d of %d converted\n", nIndex, vFiles.size());
}
else
{
printf("%d of %d %S error\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
}
}
clock_t oEndTime = clock();
double dElapsedSecs = double(oEndTime - oBeginTime) / CLOCKS_PER_SEC;
printf("%f\n", dElapsedSecs);
}
void main()
{
CDjVuFile oFile;
ConvertFolder(oFile, L"D:/Test Files//");
//ConvertFolderToRaster(oFile, L"D:/Test Files//");
ConvertFolderToPdf(oFile, L"D:/Test Files//djvu//");
char q;
std::cin >> q;
}
......@@ -99,7 +99,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;HAVE_NAMESPACES;UNICODE;_UNICODE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\freetype-2.5.2\include;D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\agg-2.4\include;D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;..\..\..\ServerComponents\DesktopEditor\freetype-2.5.2\include;..\..\..\ServerComponents\DesktopEditor\agg-2.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......@@ -131,9 +131,9 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;HAVE_NAMESPACES</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;HAVE_NAMESPACES;UNICODE;_UNICODE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>D:\Subversion\AVS\Sources\TeamlabOffice\trunk\ServerComponents\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include;..\..\..\ServerComponents\DesktopEditor\freetype-2.5.2\include;..\..\..\ServerComponents\DesktopEditor\agg-2.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......@@ -152,12 +152,15 @@
<ItemGroup>
<ClCompile Include="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\Common\DocxFormat\Source\XML\libxml2\libxml2.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\Common\DocxFormat\Source\XML\stringcommon.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="DjVuFileTest.cpp" />
<ClCompile Include="stdafx.cpp">
......
......@@ -12,11 +12,14 @@
#ifdef _DEBUG
#pragma comment(lib, "../../Common/DocxFormat/Source/XML/libxml2/win_build/x64/Debug/libxml2.lib")
#pragma comment(lib, "../x64/Debug/DjVuFile.lib")
#pragma comment(lib, "../../PdfWriter/x64/Debug/PdfWriter.lib")
#pragma comment(lib, "../../Common/DocxFormat/Source/XML/libxml2/win_build/x64/Debug/libxml2.lib")
#pragma comment(lib, "../../DesktopEditor/Qt_build/graphics/project/debug/graphics.lib")
#else
#pragma comment(lib, "../x64/Release/DjVuFile.lib")
#pragma comment(lib, "../../PdfWriter/x64/Release/PdfWriter.lib")
#pragma comment(lib, "../../Common/DocxFormat/Source/XML/libxml2/win_build/x64/Release/libxml2.lib")
#pragma comment(lib, "../../DesktopEditor/Qt_build/graphics/project/release/graphics.lib")
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment