Support disabling to pdf convertation

This commit is contained in:
Oleg Korshul
2021-10-05 11:53:37 +03:00
parent 9327fce5ca
commit 54e10c7b55
4 changed files with 21 additions and 3 deletions

View File

@ -36,7 +36,10 @@
#include "../DesktopEditor/common/Directory.h"
#include "../DesktopEditor/graphics/pro/Graphics.h"
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../PdfWriter/PdfRenderer.h"
#ifndef DISABLE_PDF_CONVERTATION
#include "../../PdfWriter/PdfRenderer.h"
#endif
#include "../OfficeUtils/src/OfficeUtils.h"
#include "../OfficeUtils/src/ZipFolder.h"
@ -256,6 +259,8 @@ void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, in
RELEASEINTERFACE(pFontManager);
RELEASEOBJECT(pRenderer);
}
#ifndef DISABLE_PDF_CONVERTATION
void CXpsFile::ConvertToPdf(const std::wstring& wsPath)
{
CPdfRenderer oPdf(m_pInternal->m_pAppFonts);
@ -288,6 +293,8 @@ void CXpsFile::ConvertToPdf(const std::wstring& wsPath)
oPdf.SaveToFile(wsPath);
}
#endif
#ifdef BUILDING_WASM_MODULE
BYTE* CXpsFile::GetStructure()
{

View File

@ -67,7 +67,10 @@ public:
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
#ifndef DISABLE_PDF_CONVERTATION
void ConvertToPdf(const std::wstring& wsDstPath);
#endif
#ifdef BUILDING_WASM_MODULE
virtual BYTE* GetStructure();
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);

View File

@ -34,9 +34,12 @@
#include "../../DesktopEditor/xml/include/xmlutils.h"
#include "../../DesktopEditor/graphics/IRenderer.h"
#include "../../DesktopEditor/graphics/structures.h"
#include "../../PdfWriter/PdfRenderer.h"
#include "../../DesktopEditor/common/File.h"
#ifndef DISABLE_PDF_CONVERTATION
#include "../../PdfWriter/PdfRenderer.h"
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
@ -186,8 +189,10 @@ namespace XPS
if (!m_pColors || !m_pPositions || !m_lCount)
return false;
#ifndef DISABLE_PDF_CONVERTATION
LONG lRendererType = c_nUnknownRenderer;
pRenderer->get_Type(&lRendererType);
if (c_nPDFWriter == lRendererType)
{
CPdfRenderer* pPdf = (CPdfRenderer*)pRenderer;
@ -195,6 +200,7 @@ namespace XPS
pPdf->SetLinearGradient(m_dX0, m_dY0, m_dX1, m_dY1);
}
else
#endif
{
double dX = m_dX1 - m_dX0, dY = m_dY1 - m_dY0;
double dHyp = sqrt(dX * dX + dY * dY);
@ -210,8 +216,10 @@ namespace XPS
if (!m_pColors || !m_pPositions || !m_lCount)
return false;
#ifndef DISABLE_PDF_CONVERTATION
LONG lRendererType = c_nUnknownRenderer;
pRenderer->get_Type(&lRendererType);
if (c_nPDFWriter == lRendererType)
{
CPdfRenderer* pPdf = (CPdfRenderer*)pRenderer;
@ -219,6 +227,7 @@ namespace XPS
pPdf->SetRadialGradient(m_dXo, m_dYo, 0, m_dXc, m_dYc, std::max(m_dRadX, m_dRadY));
}
else
#endif
{
pRenderer->put_BrushType(c_BrushTypePathGradient2);
pRenderer->put_BrushGradientColors(m_pColors, m_pPositions, m_lCount);

View File

@ -34,7 +34,6 @@
#include "../../DesktopEditor/common/StringExt.h"
#include "../../DesktopEditor/graphics/structures.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../PdfWriter/PdfRenderer.h"
#include "Document.h"
#include "StaticResources.h"