mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix pdf bugs (add build with embedded fonts in changes)
This commit is contained in:
@ -127,7 +127,12 @@ public:
|
|||||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||||
{
|
{
|
||||||
RELEASEOBJECT(m_pFile);
|
if (4 != ((CPdfFile*)m_pFile)->GetError())
|
||||||
|
{
|
||||||
|
RELEASEOBJECT(m_pFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_nType = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_nType = 0;
|
m_nType = 0;
|
||||||
@ -167,7 +172,12 @@ public:
|
|||||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||||
{
|
{
|
||||||
RELEASEOBJECT(m_pFile);
|
if (4 != ((CPdfFile*)m_pFile)->GetError())
|
||||||
|
{
|
||||||
|
RELEASEOBJECT(m_pFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_nType = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_nType = 0;
|
m_nType = 0;
|
||||||
@ -484,6 +494,14 @@ public:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring GetFontBinaryNative(const std::wstring& sName)
|
||||||
|
{
|
||||||
|
if (0 != m_nType)
|
||||||
|
return L"";
|
||||||
|
|
||||||
|
return ((CPdfFile*)m_pFile)->GetEmbeddedFontPath(sName);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int GetPagesCount()
|
int GetPagesCount()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,6 +71,19 @@ JSSmart<CJSValue> CDrawingFileEmbed::DestroyPixmap(JSSmart<CJSValue> typedArray)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSSmart<CJSValue> CDrawingFileEmbed::GetFontBinary(JSSmart<CJSValue> Id)
|
||||||
|
{
|
||||||
|
if (0 != m_pFile->GetType())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
std::wstring sName = Id->toStringW();
|
||||||
|
std::wstring sFile = m_pFile->GetFontBinaryNative(sName);
|
||||||
|
if (sFile.empty())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return CJSContext::createUint8Array(sFile);
|
||||||
|
}
|
||||||
|
|
||||||
JSSmart<CJSValue> CDrawingFileEmbed::GetGlyphs(JSSmart<CJSValue> nPageIndex)
|
JSSmart<CJSValue> CDrawingFileEmbed::GetGlyphs(JSSmart<CJSValue> nPageIndex)
|
||||||
{
|
{
|
||||||
return WasmMemoryToJS(m_pFile->GetGlyphs(nPageIndex->toInt32()));
|
return WasmMemoryToJS(m_pFile->GetGlyphs(nPageIndex->toInt32()));
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public:
|
|||||||
JSSmart<CJSValue> GetAnnotationsInfo(JSSmart<CJSValue> nPageIndex);
|
JSSmart<CJSValue> GetAnnotationsInfo(JSSmart<CJSValue> nPageIndex);
|
||||||
JSSmart<CJSValue> GetAnnotationsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nAnnot, JSSmart<CJSValue> nView);
|
JSSmart<CJSValue> GetAnnotationsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nAnnot, JSSmart<CJSValue> nView);
|
||||||
|
|
||||||
|
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> Id);
|
||||||
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
||||||
JSSmart<CJSValue> DestroyTextInfo();
|
JSSmart<CJSValue> DestroyTextInfo();
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
-(JSValue*) GetButtonIcons : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)bBase64 : (JSValue*)nButtonWidget : (JSValue*)nIconView;
|
-(JSValue*) GetButtonIcons : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)bBase64 : (JSValue*)nButtonWidget : (JSValue*)nIconView;
|
||||||
-(JSValue*) GetAnnotationsInfo : (JSValue*)nPageIndex;
|
-(JSValue*) GetAnnotationsInfo : (JSValue*)nPageIndex;
|
||||||
-(JSValue*) GetAnnotationsAP : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)nAnnot : (JSValue*)nView;
|
-(JSValue*) GetAnnotationsAP : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)nAnnot : (JSValue*)nView;
|
||||||
|
-(JSValue*) GetFontBinary : (JSValue*)Id;
|
||||||
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
||||||
-(JSValue*) DestroyTextInfo;
|
-(JSValue*) DestroyTextInfo;
|
||||||
-(JSValue*) IsNeedCMap;
|
-(JSValue*) IsNeedCMap;
|
||||||
@ -53,6 +54,7 @@ FUNCTION_WRAPPER_JS_7(GetInteractiveFormsAP, GetInteractiveFormsAP)
|
|||||||
FUNCTION_WRAPPER_JS_5(GetButtonIcons, GetButtonIcons)
|
FUNCTION_WRAPPER_JS_5(GetButtonIcons, GetButtonIcons)
|
||||||
FUNCTION_WRAPPER_JS_1(GetAnnotationsInfo, GetAnnotationsInfo)
|
FUNCTION_WRAPPER_JS_1(GetAnnotationsInfo, GetAnnotationsInfo)
|
||||||
FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
||||||
|
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary)
|
||||||
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
||||||
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
||||||
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace NSDrawingFileEmbed
|
|||||||
FUNCTION_WRAPPER_V8_5(_GetButtonIcons, GetButtonIcons)
|
FUNCTION_WRAPPER_V8_5(_GetButtonIcons, GetButtonIcons)
|
||||||
FUNCTION_WRAPPER_V8_1(_GetAnnotationsInfo, GetAnnotationsInfo)
|
FUNCTION_WRAPPER_V8_1(_GetAnnotationsInfo, GetAnnotationsInfo)
|
||||||
FUNCTION_WRAPPER_V8_6(_GetAnnotationsAP, GetAnnotationsAP)
|
FUNCTION_WRAPPER_V8_6(_GetAnnotationsAP, GetAnnotationsAP)
|
||||||
|
FUNCTION_WRAPPER_V8_1(_GetFontBinary, GetFontBinary)
|
||||||
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
||||||
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
||||||
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
||||||
@ -51,6 +52,7 @@ namespace NSDrawingFileEmbed
|
|||||||
NSV8Objects::Template_Set(result, "GetButtonIcons", _GetButtonIcons);
|
NSV8Objects::Template_Set(result, "GetButtonIcons", _GetButtonIcons);
|
||||||
NSV8Objects::Template_Set(result, "GetAnnotationsInfo", _GetAnnotationsInfo);
|
NSV8Objects::Template_Set(result, "GetAnnotationsInfo", _GetAnnotationsInfo);
|
||||||
NSV8Objects::Template_Set(result, "GetAnnotationsAP", _GetAnnotationsAP);
|
NSV8Objects::Template_Set(result, "GetAnnotationsAP", _GetAnnotationsAP);
|
||||||
|
NSV8Objects::Template_Set(result, "GetFontBinary", _GetFontBinary);
|
||||||
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
||||||
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
||||||
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
||||||
|
|||||||
@ -115,7 +115,7 @@ CFile.prototype["loadFromDataWithPassword"] = function(password)
|
|||||||
if (0 != this.nativeFile)
|
if (0 != this.nativeFile)
|
||||||
this._closeFile();
|
this._closeFile();
|
||||||
|
|
||||||
let isSuccess = this._openFile(arrayBuffer, password);
|
let isSuccess = this._openFile(undefined, password);
|
||||||
let error = this._getError(); // 0 - ok, 4 - password, else: error
|
let error = this._getError(); // 0 - ok, 4 - password, else: error
|
||||||
this.type = this._getType();
|
this.type = this._getType();
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,7 @@ CFile.prototype._setCMap = function(memoryBuffer)
|
|||||||
|
|
||||||
CFile.prototype._getFontByID = function(ID)
|
CFile.prototype._getFontByID = function(ID)
|
||||||
{
|
{
|
||||||
return null;
|
return g_native_drawing_file["GetFontBinary"](ID);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||||
|
|||||||
@ -82,7 +82,7 @@ CFile.prototype._getUint8ClampedArray = function(ptr, len)
|
|||||||
// FILE
|
// FILE
|
||||||
CFile.prototype._openFile = function(buffer, password)
|
CFile.prototype._openFile = function(buffer, password)
|
||||||
{
|
{
|
||||||
if (this.stream && buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
let data = new Uint8Array(buffer);
|
let data = new Uint8Array(buffer);
|
||||||
this.stream_size = data.length;
|
this.stream_size = data.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user