mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
fix some problems
This commit is contained in:
@ -52,8 +52,13 @@ public:
|
|||||||
virtual int GetPagesCount() = 0;
|
virtual int GetPagesCount() = 0;
|
||||||
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) = 0;
|
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) = 0;
|
||||||
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak) = 0;
|
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak) = 0;
|
||||||
virtual unsigned char* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH) = 0;
|
virtual unsigned char* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false) = 0;
|
||||||
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1) = 0;
|
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1) = 0;
|
||||||
|
#ifdef BUILDING_WASM_MODULE
|
||||||
|
virtual unsigned char* GetStructure() = 0;
|
||||||
|
virtual unsigned char* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH) = 0;
|
||||||
|
virtual unsigned char* GetLinks (int nPageIndex, int nRasterW, int nRasterH) = 0;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _OFFICE_DRAWING_FILE_H
|
#endif // _OFFICE_DRAWING_FILE_H
|
||||||
|
|||||||
@ -42,19 +42,14 @@ compiler_flags = ["-O3",
|
|||||||
|
|
||||||
exported_functions = ["_malloc",
|
exported_functions = ["_malloc",
|
||||||
"_free",
|
"_free",
|
||||||
"_XPS_Load",
|
"_GetType",
|
||||||
"_DJVU_Load",
|
"_Open",
|
||||||
"_PDF_Load",
|
"_Close",
|
||||||
"_XPS_Close",
|
"_GetInfo",
|
||||||
"_XPS_GetInfo",
|
"_GetPixmap",
|
||||||
"_XPS_GetPixmap",
|
"_GetGlyphs",
|
||||||
"_XPS_GetGlyphs",
|
"_GetLinks",
|
||||||
"_DJVU_GetGlyphs",
|
"_GetStructure"]
|
||||||
"_XPS_GetLinks",
|
|
||||||
"_DJVU_GetLinks",
|
|
||||||
"_XPS_GetStructure",
|
|
||||||
"_DJVU_GetStructure",
|
|
||||||
"_XPS_Delete"]
|
|
||||||
|
|
||||||
libGraphics_src_path = "../../"
|
libGraphics_src_path = "../../"
|
||||||
input_graphics_sources = ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp"]
|
input_graphics_sources = ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp"]
|
||||||
@ -110,7 +105,7 @@ input_cryptopp_sources = ["cryptlib.cpp", #"cpu.cpp",
|
|||||||
"sha.cpp"] #"sha3.cpp", "shacal2-simd.cpp", "shacal2.cpp", "shark.cpp", "sharkbox.cpp", "skipjack.cpp", "socketft.cpp", "sosemanuk.cpp", "square.cpp", "squaretb.cpp", "sse-simd.cpp", "strciphr.cpp", "tea.cpp", "tftables.cpp", "threefish.cpp", "tiger.cpp", "tigertab.cpp", "trdlocal.cpp", "ttmac.cpp", "twofish.cpp", "vmac.cpp", "wait.cpp", "wake.cpp", "whrlpool.cpp", "xtr.cpp", "xtrcrypt.cpp", "zdeflate.cpp", "zinflate.cpp", "zlib.cpp"]
|
"sha.cpp"] #"sha3.cpp", "shacal2-simd.cpp", "shacal2.cpp", "shark.cpp", "sharkbox.cpp", "skipjack.cpp", "socketft.cpp", "sosemanuk.cpp", "square.cpp", "squaretb.cpp", "sse-simd.cpp", "strciphr.cpp", "tea.cpp", "tftables.cpp", "threefish.cpp", "tiger.cpp", "tigertab.cpp", "trdlocal.cpp", "ttmac.cpp", "twofish.cpp", "vmac.cpp", "wait.cpp", "wake.cpp", "whrlpool.cpp", "xtr.cpp", "xtrcrypt.cpp", "zdeflate.cpp", "zinflate.cpp", "zlib.cpp"]
|
||||||
|
|
||||||
libPdfReader_src_path = "../../../../PdfReader/Src/"
|
libPdfReader_src_path = "../../../../PdfReader/Src/"
|
||||||
input_pdfreader_sources = ["Annot.cpp", "Array.cpp", "Catalog.cpp", "CharCodeToUnicode.cpp", "CMap.cpp", "Decrypt.cpp", "Dict.cpp", "ExtractImageOutputDev.cpp", "FontFileBase.cpp", "FontFileTrueType.cpp", "FontFileType1.cpp", "FontFileType1C.cpp", "Function.cpp", "GFont.cpp", "GlobalParams.cpp", "PDFGraphics.cpp", "GState.cpp", "Hash.cpp", "JArithmeticDecoder.cpp", "JBIG2Stream.cpp", "JPXStream.cpp", "Lexer.cpp", "Link.cpp", "List.cpp", "NameToCharCode.cpp", "Object.cpp", "Outline.cpp", "OutputDevice.cpp", "Page.cpp", "PageLabels.cpp", "Parser.cpp", "PDFDoc.cpp", "PSLexer.cpp", "RendererOutputDev.cpp", "SecurityHandler.cpp", "Stream.cpp", "StringExt.cpp", "UnicodeMap.cpp", "XRef.cpp"]
|
input_pdfreader_sources = ["Annot.cpp", "Array.cpp", "Catalog.cpp", "CharCodeToUnicode.cpp", "CMap.cpp", "Decrypt.cpp", "Dict.cpp", "ExtractImageOutputDev.cpp", "FontFileBase.cpp", "FontFileTrueType.cpp", "FontFileType1.cpp", "FontFileType1C.cpp", "Function.cpp", "GFont.cpp", "GlobalParams.cpp", "Graphics.cpp", "GState.cpp", "Hash.cpp", "JArithmeticDecoder.cpp", "JBIG2Stream.cpp", "JPXStream.cpp", "Lexer.cpp", "Link.cpp", "List.cpp", "NameToCharCode.cpp", "Object.cpp", "Outline.cpp", "OutputDevice.cpp", "Page.cpp", "PageLabels.cpp", "Parser.cpp", "PDFDoc.cpp", "PSLexer.cpp", "RendererOutputDev.cpp", "SecurityHandler.cpp", "Stream.cpp", "StringExt.cpp", "UnicodeMap.cpp", "XRef.cpp"]
|
||||||
|
|
||||||
# sources
|
# sources
|
||||||
sources = []
|
sources = []
|
||||||
@ -144,7 +139,7 @@ sources.append("../../../../HtmlRenderer/src/HTMLRenderer3.cpp")
|
|||||||
sources.append("../../../../PdfReader/PdfReader.cpp")
|
sources.append("../../../../PdfReader/PdfReader.cpp")
|
||||||
# pdfReader
|
# pdfReader
|
||||||
sources.append("raster.o")
|
sources.append("raster.o")
|
||||||
sources.append("wasm/src/wasmgraphics.cpp")
|
sources.append("wasm/src/drawingfile.cpp")
|
||||||
|
|
||||||
compiler_flags.append("-I../../../agg-2.4/include -I../../../cximage/jasper/include -I../../../cximage/jpeg -I../../../cximage/png -I../../../freetype-2.10.4/include -I../../../freetype-2.10.4/include/freetype -I../../../../OfficeUtils/src/zlib-1.2.11 -I../../../../Common/3dParty/icu/icu/source/common -I../../../xml/libxml2/include -I../../../xml/build/qt -I../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip -I../../../../OfficeUtils/src/zlib-1.2.11")
|
compiler_flags.append("-I../../../agg-2.4/include -I../../../cximage/jasper/include -I../../../cximage/jpeg -I../../../cximage/png -I../../../freetype-2.10.4/include -I../../../freetype-2.10.4/include/freetype -I../../../../OfficeUtils/src/zlib-1.2.11 -I../../../../Common/3dParty/icu/icu/source/common -I../../../xml/libxml2/include -I../../../xml/build/qt -I../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip -I../../../../OfficeUtils/src/zlib-1.2.11")
|
||||||
compiler_flags.append("-D__linux__ -D_LINUX -DUNIX -DFT2_BUILD_LIBRARY -DHAVE_FCNTL_H -DFT_CONFIG_OPTION_SYSTEM_ZLIB -DBUILDING_WASM_MODULE -DU_COMMON_IMPLEMENTATION")
|
compiler_flags.append("-D__linux__ -D_LINUX -DUNIX -DFT2_BUILD_LIBRARY -DHAVE_FCNTL_H -DFT_CONFIG_OPTION_SYSTEM_ZLIB -DBUILDING_WASM_MODULE -DU_COMMON_IMPLEMENTATION")
|
||||||
@ -203,7 +198,7 @@ if base.host_platform() == "windows":
|
|||||||
for item in sources:
|
for item in sources:
|
||||||
arguments += (item + " ")
|
arguments += (item + " ")
|
||||||
|
|
||||||
windows_bat.append("call emcc -o xps_djvu_pdf.js " + arguments + libs)
|
windows_bat.append("call emcc -o drawingfile.js " + arguments + libs)
|
||||||
else:
|
else:
|
||||||
windows_bat.append("#!/bin/bash")
|
windows_bat.append("#!/bin/bash")
|
||||||
windows_bat.append("source ./emsdk/emsdk_env.sh")
|
windows_bat.append("source ./emsdk/emsdk_env.sh")
|
||||||
@ -250,14 +245,14 @@ else:
|
|||||||
for item in sources:
|
for item in sources:
|
||||||
arguments += (item + " ")
|
arguments += (item + " ")
|
||||||
|
|
||||||
windows_bat.append("emcc -o xps_djvu_pdf.js " + arguments + libs)
|
windows_bat.append("emcc -o drawingfile.js " + arguments + libs)
|
||||||
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
|
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
|
||||||
base.run_as_bat(windows_bat)
|
base.run_as_bat(windows_bat)
|
||||||
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;", "\n{\n UDataMemory tData;")
|
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;", "\n{\n UDataMemory tData;")
|
||||||
|
|
||||||
# finalize
|
# finalize
|
||||||
base.replaceInFile("./xps_djvu_pdf.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
|
base.replaceInFile("./drawingfile.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
|
||||||
graphics_js_content = base.readFile("./xps_djvu_pdf.js")
|
graphics_js_content = base.readFile("./drawingfile.js")
|
||||||
engine_base_js_content = base.readFile("./wasm/js/xps_base.js")
|
engine_base_js_content = base.readFile("./wasm/js/xps_base.js")
|
||||||
string_utf8_content = base.readFile("./../../../../Common/js/string_utf8.js")
|
string_utf8_content = base.readFile("./../../../../Common/js/string_utf8.js")
|
||||||
engine_js_content = engine_base_js_content.replace("//module", graphics_js_content)
|
engine_js_content = engine_base_js_content.replace("//module", graphics_js_content)
|
||||||
@ -273,10 +268,10 @@ pdf_js_content = pdf_js_content.replace("//string_utf8", string_utf8_content)
|
|||||||
base.writeFile("./deploy/xps.js", engine_js_content)
|
base.writeFile("./deploy/xps.js", engine_js_content)
|
||||||
base.writeFile("./deploy/djvu.js", djvu_js_content)
|
base.writeFile("./deploy/djvu.js", djvu_js_content)
|
||||||
base.writeFile("./deploy/pdf.js", pdf_js_content)
|
base.writeFile("./deploy/pdf.js", pdf_js_content)
|
||||||
base.copy_file("./xps_djvu_pdf.wasm", "./deploy/xps_djvu_pdf.wasm")
|
base.copy_file("./drawingfile.wasm", "./deploy/drawingfile.wasm")
|
||||||
|
|
||||||
base.delete_file("xps_djvu_pdf.js")
|
base.delete_file("drawingfile.js")
|
||||||
base.delete_file("xps_djvu_pdf.wasm")
|
base.delete_file("drawingfile.wasm")
|
||||||
base.delete_dir("./temp")
|
base.delete_dir("./temp")
|
||||||
base.delete_dir("./xml")
|
base.delete_dir("./xml")
|
||||||
# base.delete_file("raster.o")
|
# base.delete_file("raster.o")
|
||||||
|
|||||||
@ -68,7 +68,6 @@ HEADERS += \
|
|||||||
../../../MetafileToRendererCheck.h \
|
../../../MetafileToRendererCheck.h \
|
||||||
../../../MetafileToGraphicsRenderer.h \
|
../../../MetafileToGraphicsRenderer.h \
|
||||||
../../../structures.h \
|
../../../structures.h \
|
||||||
../../../Graphics.h \
|
|
||||||
../../../GraphicsRenderer.h \
|
../../../GraphicsRenderer.h \
|
||||||
\
|
\
|
||||||
../../../../fontengine/ApplicationFonts.h \
|
../../../../fontengine/ApplicationFonts.h \
|
||||||
@ -639,7 +638,7 @@ HEADERS +=\
|
|||||||
$$PDF_ROOT_DIR/Src/Function.h \
|
$$PDF_ROOT_DIR/Src/Function.h \
|
||||||
$$PDF_ROOT_DIR/Src/GFont.h \
|
$$PDF_ROOT_DIR/Src/GFont.h \
|
||||||
$$PDF_ROOT_DIR/Src/GlobalParams.h \
|
$$PDF_ROOT_DIR/Src/GlobalParams.h \
|
||||||
$$PDF_ROOT_DIR/Src/PDFGraphics.h \
|
$$PDF_ROOT_DIR/Src/Graphics.h \
|
||||||
$$PDF_ROOT_DIR/Src/GState.h \
|
$$PDF_ROOT_DIR/Src/GState.h \
|
||||||
$$PDF_ROOT_DIR/Src/Hash.h \
|
$$PDF_ROOT_DIR/Src/Hash.h \
|
||||||
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.h \
|
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.h \
|
||||||
@ -687,7 +686,7 @@ SOURCES += \
|
|||||||
$$PDF_ROOT_DIR/Src/Function.cpp \
|
$$PDF_ROOT_DIR/Src/Function.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/GFont.cpp \
|
$$PDF_ROOT_DIR/Src/GFont.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/GlobalParams.cpp \
|
$$PDF_ROOT_DIR/Src/GlobalParams.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/PDFGraphics.cpp \
|
$$PDF_ROOT_DIR/Src/Graphics.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/GState.cpp \
|
$$PDF_ROOT_DIR/Src/GState.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/Hash.cpp \
|
$$PDF_ROOT_DIR/Src/Hash.cpp \
|
||||||
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.cpp \
|
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.cpp \
|
||||||
@ -713,5 +712,5 @@ SOURCES += \
|
|||||||
$$PDF_ROOT_DIR/Src/XRef.cpp \
|
$$PDF_ROOT_DIR/Src/XRef.cpp \
|
||||||
$$PDF_ROOT_DIR/PdfReader.cpp
|
$$PDF_ROOT_DIR/PdfReader.cpp
|
||||||
|
|
||||||
HEADERS += ../wasm/src/wasmgraphics.h
|
HEADERS += ../wasm/src/drawingfile.h
|
||||||
SOURCES += ../wasm/src/wasmgraphics.cpp
|
SOURCES += ../wasm/src/drawingfile.cpp
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
var data = new Uint8Array(arrayBuffer);
|
var data = new Uint8Array(arrayBuffer);
|
||||||
var _stream = Module["_malloc"](data.length);
|
var _stream = Module["_malloc"](data.length);
|
||||||
Module["HEAP8"].set(data, _stream);
|
Module["HEAP8"].set(data, _stream);
|
||||||
this.nativeFile = Module["_PDF_Load"](_stream, data.length);
|
this.nativeFile = Module["_Open"](_stream, data.length);
|
||||||
this.stream = _stream;
|
this.stream = _stream;
|
||||||
return this.getInfo();
|
return this.getInfo();
|
||||||
};
|
};
|
||||||
@ -106,7 +106,7 @@
|
|||||||
if (!this.nativeFile)
|
if (!this.nativeFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var _info = Module["_XPS_GetInfo"](this.nativeFile);
|
var _info = Module["_GetInfo"](this.nativeFile);
|
||||||
if (!_info)
|
if (!_info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -124,12 +124,22 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
return Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
||||||
};
|
};
|
||||||
|
CFile.prototype.getGlyphs = function(pageIndex, width, height)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
CFile.prototype.getLinks = function(pageIndex, width, height)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
CFile.prototype.structure = function()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
};
|
||||||
CFile.prototype.close = function()
|
CFile.prototype.close = function()
|
||||||
{
|
{
|
||||||
Module["_XPS_Close"](this.nativeFile);
|
Module["_Close"](this.nativeFile);
|
||||||
this.nativeFile = 0;
|
this.nativeFile = 0;
|
||||||
this.pages = [];
|
this.pages = [];
|
||||||
if (this.stream > 0)
|
if (this.stream > 0)
|
||||||
@ -142,7 +152,7 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.free = function(pointer)
|
CFile.prototype.free = function(pointer)
|
||||||
{
|
{
|
||||||
Module["_XPS_Delete"](pointer);
|
Module["_free"](pointer);
|
||||||
};
|
};
|
||||||
|
|
||||||
window["AscViewer"].PdfFile = CFile;
|
window["AscViewer"].PdfFile = CFile;
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
var data = new Uint8Array(arrayBuffer);
|
var data = new Uint8Array(arrayBuffer);
|
||||||
var _stream = Module["_malloc"](data.length);
|
var _stream = Module["_malloc"](data.length);
|
||||||
Module["HEAP8"].set(data, _stream);
|
Module["HEAP8"].set(data, _stream);
|
||||||
this.nativeFile = Module["_XPS_Load"](_stream, data.length);
|
this.nativeFile = Module["_Open"](_stream, data.length);
|
||||||
Module["_free"](_stream);
|
Module["_free"](_stream);
|
||||||
return this.getInfo();
|
return this.getInfo();
|
||||||
};
|
};
|
||||||
@ -106,7 +106,7 @@
|
|||||||
if (!this.nativeFile)
|
if (!this.nativeFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var _info = Module["_XPS_GetInfo"](this.nativeFile);
|
var _info = Module["_GetInfo"](this.nativeFile);
|
||||||
if (!_info)
|
if (!_info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -124,11 +124,11 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
return Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
||||||
};
|
};
|
||||||
CFile.prototype.getGlyphs = function(pageIndex, width, height)
|
CFile.prototype.getGlyphs = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
var glyphs = Module["_XPS_GetGlyphs"](this.nativeFile, pageIndex, width, height);
|
var glyphs = Module["_GetGlyphs"](this.nativeFile, pageIndex, width, height);
|
||||||
if (glyphs == null)
|
if (glyphs == null)
|
||||||
return;
|
return;
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
|
||||||
@ -208,12 +208,12 @@
|
|||||||
prevY = glyph.Y;
|
prevY = glyph.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Module["_XPS_Delete"](glyphs);
|
Module["_free"](glyphs);
|
||||||
};
|
};
|
||||||
CFile.prototype.getLinks = function(pageIndex, width, height)
|
CFile.prototype.getLinks = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
var res = [];
|
var res = [];
|
||||||
var ext = Module["_XPS_GetLinks"](this.nativeFile, pageIndex, width, height);
|
var ext = Module["_GetLinks"](this.nativeFile, pageIndex, width, height);
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
|
||||||
if (lenArray == null)
|
if (lenArray == null)
|
||||||
return res;
|
return res;
|
||||||
@ -250,13 +250,13 @@
|
|||||||
res.push({ X : _X * 1.015, Y : _Y * 1.015, W : _W, H : _H, Link : _Link});
|
res.push({ X : _X * 1.015, Y : _Y * 1.015, W : _W, H : _H, Link : _Link});
|
||||||
}
|
}
|
||||||
|
|
||||||
Module["_XPS_Delete"](ext);
|
Module["_free"](ext);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
CFile.prototype.structure = function()
|
CFile.prototype.structure = function()
|
||||||
{
|
{
|
||||||
var res = [];
|
var res = [];
|
||||||
var str = Module["_XPS_GetStructure"](this.nativeFile);
|
var str = Module["_GetStructure"](this.nativeFile);
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
|
||||||
if (lenArray == null)
|
if (lenArray == null)
|
||||||
return res;
|
return res;
|
||||||
@ -289,12 +289,12 @@
|
|||||||
res.push({ page : _Page, level : _Level, Y : _Y, description : _Description});
|
res.push({ page : _Page, level : _Level, Y : _Y, description : _Description});
|
||||||
}
|
}
|
||||||
|
|
||||||
Module["_XPS_Delete"](str);
|
Module["_free"](str);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
CFile.prototype.close = function()
|
CFile.prototype.close = function()
|
||||||
{
|
{
|
||||||
Module["_XPS_Close"](this.nativeFile);
|
Module["_Close"](this.nativeFile);
|
||||||
this.nativeFile = 0;
|
this.nativeFile = 0;
|
||||||
this.pages = [];
|
this.pages = [];
|
||||||
};
|
};
|
||||||
@ -304,7 +304,7 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.free = function(pointer)
|
CFile.prototype.free = function(pointer)
|
||||||
{
|
{
|
||||||
Module["_XPS_Delete"](pointer);
|
Module["_free"](pointer);
|
||||||
};
|
};
|
||||||
|
|
||||||
window["AscViewer"].XpsFile = CFile;
|
window["AscViewer"].XpsFile = CFile;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#include "../../../../GraphicsRenderer.h"
|
#include "../../../../GraphicsRenderer.h"
|
||||||
#include "../../../../pro/Graphics.h"
|
#include "../../../../pro/Graphics.h"
|
||||||
#include "../../../../../common/Base64.h"
|
#include "../../../../../common/Base64.h"
|
||||||
#include "wasmgraphics.h"
|
#include "drawingfile.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WASM_EXPORT __declspec(dllexport)
|
#define WASM_EXPORT __declspec(dllexport)
|
||||||
@ -18,39 +18,37 @@ CGlobalFontsMemoryStorage* CApplicationFontStreams::m_pMemoryStorage = NULL;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WASM_EXPORT CGraphicsFileDrawing* XPS_Load (BYTE* data, LONG size)
|
WASM_EXPORT int GetType (BYTE* data, LONG size)
|
||||||
|
{
|
||||||
|
// 0 - PDF
|
||||||
|
// 1 - DJVU
|
||||||
|
// 2 - XPS
|
||||||
|
char* pFirst = strstr((char*)data, "%PDF-" );
|
||||||
|
if (pFirst)
|
||||||
|
return 0;
|
||||||
|
if ( (8 <= size) && (0x41 == data[0] && 0x54 == data[1] && 0x26 == data[2] && 0x54 == data[3] &&
|
||||||
|
0x46 == data[4] && 0x4f == data[5] && 0x52 == data[6] && 0x4d == data[7]))
|
||||||
|
return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
WASM_EXPORT CGraphicsFileDrawing* Open(BYTE* data, LONG size)
|
||||||
{
|
{
|
||||||
CGraphicsFileDrawing* pGraphics = new CGraphicsFileDrawing();
|
CGraphicsFileDrawing* pGraphics = new CGraphicsFileDrawing();
|
||||||
pGraphics->CreateXPS();
|
if (pGraphics->Open(data, size, GetType(data, size)))
|
||||||
if (!CApplicationFontStreams::m_pMemoryStorage)
|
{
|
||||||
CApplicationFontStreams::m_pMemoryStorage = new CGlobalFontsMemoryStorage();
|
if (!CApplicationFontStreams::m_pMemoryStorage)
|
||||||
pGraphics->LoadFromMemory(data, size);
|
CApplicationFontStreams::m_pMemoryStorage = new CGlobalFontsMemoryStorage();
|
||||||
return pGraphics;
|
return pGraphics;
|
||||||
|
}
|
||||||
|
delete pGraphics;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
WASM_EXPORT CGraphicsFileDrawing* DJVU_Load(BYTE* data, LONG size)
|
WASM_EXPORT void Close (CGraphicsFileDrawing* pGraphics)
|
||||||
{
|
|
||||||
CGraphicsFileDrawing* pGraphics = new CGraphicsFileDrawing();
|
|
||||||
pGraphics->CreateDjVu();
|
|
||||||
if (!CApplicationFontStreams::m_pMemoryStorage)
|
|
||||||
CApplicationFontStreams::m_pMemoryStorage = new CGlobalFontsMemoryStorage();
|
|
||||||
pGraphics->LoadFromMemory(data, size);
|
|
||||||
return pGraphics;
|
|
||||||
}
|
|
||||||
WASM_EXPORT CGraphicsFileDrawing* PDF_Load (BYTE* data, LONG size)
|
|
||||||
{
|
|
||||||
CGraphicsFileDrawing* pGraphics = new CGraphicsFileDrawing();
|
|
||||||
pGraphics->CreatePDF();
|
|
||||||
if (!CApplicationFontStreams::m_pMemoryStorage)
|
|
||||||
CApplicationFontStreams::m_pMemoryStorage = new CGlobalFontsMemoryStorage();
|
|
||||||
pGraphics->LoadFromMemory(data, size);
|
|
||||||
return pGraphics;
|
|
||||||
}
|
|
||||||
WASM_EXPORT void XPS_Close (CGraphicsFileDrawing* pGraphics)
|
|
||||||
{
|
{
|
||||||
delete pGraphics;
|
delete pGraphics;
|
||||||
RELEASEOBJECT(CApplicationFontStreams::m_pMemoryStorage);
|
RELEASEOBJECT(CApplicationFontStreams::m_pMemoryStorage);
|
||||||
}
|
}
|
||||||
WASM_EXPORT int* XPS_GetInfo (CGraphicsFileDrawing* pGraphics)
|
WASM_EXPORT int* GetInfo (CGraphicsFileDrawing* pGraphics)
|
||||||
{
|
{
|
||||||
int pages_count = pGraphics->GetPagesCount();
|
int pages_count = pGraphics->GetPagesCount();
|
||||||
int* buffer = new int[pages_count * 3 + 1];
|
int* buffer = new int[pages_count * 3 + 1];
|
||||||
@ -68,37 +66,21 @@ WASM_EXPORT int* XPS_GetInfo (CGraphicsFileDrawing* pGraphics)
|
|||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* XPS_GetPixmap (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
WASM_EXPORT BYTE* GetPixmap (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
||||||
{
|
{
|
||||||
return pGraphics->GetPage(nPageIndex, nRasterW, nRasterH);
|
return pGraphics->GetPage(nPageIndex, nRasterW, nRasterH);
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* XPS_GetGlyphs (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
WASM_EXPORT BYTE* GetGlyphs (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
||||||
{
|
{
|
||||||
return pGraphics->GetXPSGlyphs(nPageIndex, nRasterW, nRasterH);
|
return pGraphics->GetGlyphs(nPageIndex, nRasterW, nRasterH);
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* DJVU_GetGlyphs(CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
WASM_EXPORT BYTE* GetLinks (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
||||||
{
|
{
|
||||||
return pGraphics->GetDJVUGlyphs(nPageIndex, nRasterW, nRasterH);
|
return pGraphics->GetLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* XPS_GetLinks(CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
WASM_EXPORT BYTE* GetStructure(CGraphicsFileDrawing* pGraphics)
|
||||||
{
|
{
|
||||||
return pGraphics->GetXPSLinks(nPageIndex, nRasterW, nRasterH);
|
return pGraphics->GetStructure();
|
||||||
}
|
|
||||||
WASM_EXPORT BYTE* DJVU_GetLinks(CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
return pGraphics->GetDJVULinks(nPageIndex, nRasterW, nRasterH);
|
|
||||||
}
|
|
||||||
WASM_EXPORT BYTE* XPS_GetStructure(CGraphicsFileDrawing* pGraphics)
|
|
||||||
{
|
|
||||||
return pGraphics->GetXPSStructure();
|
|
||||||
}
|
|
||||||
WASM_EXPORT BYTE* DJVU_GetStructure(CGraphicsFileDrawing* pGraphics)
|
|
||||||
{
|
|
||||||
return pGraphics->GetDJVUStructure();
|
|
||||||
}
|
|
||||||
WASM_EXPORT void XPS_Delete(BYTE* pData)
|
|
||||||
{
|
|
||||||
RELEASEARRAYOBJECTS(pData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -127,15 +109,15 @@ int main()
|
|||||||
}
|
}
|
||||||
oFile.CloseFile();
|
oFile.CloseFile();
|
||||||
|
|
||||||
CGraphicsFileDrawing* test = PDF_Load(pPdfData, nPdfBytesCount);
|
CGraphicsFileDrawing* test = Open(pPdfData, nPdfBytesCount);
|
||||||
int* info = XPS_GetInfo(test);
|
int* info = GetInfo(test);
|
||||||
int pages_count = *info;
|
int pages_count = *info;
|
||||||
int width = info[1] * 96 / info[3];
|
int width = info[1] * 96 / info[3];
|
||||||
int height = info[2] * 96 / info[3];
|
int height = info[2] * 96 / info[3];
|
||||||
|
|
||||||
BYTE* res = NULL;
|
BYTE* res = NULL;
|
||||||
if (pages_count > 0)
|
if (pages_count > 0)
|
||||||
res = XPS_GetPixmap(test, 0, width, height);
|
res = GetPixmap(test, 0, width, height);
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
std::cout << (int)res[i] << " ";
|
std::cout << (int)res[i] << " ";
|
||||||
@ -150,7 +132,7 @@ int main()
|
|||||||
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
||||||
resFrame->ClearNoAttack();
|
resFrame->ClearNoAttack();
|
||||||
|
|
||||||
XPS_Close(test);
|
Close(test);
|
||||||
RELEASEARRAYOBJECTS(pPdfData);
|
RELEASEARRAYOBJECTS(pPdfData);
|
||||||
RELEASEARRAYOBJECTS(info);
|
RELEASEARRAYOBJECTS(info);
|
||||||
RELEASEARRAYOBJECTS(res);
|
RELEASEARRAYOBJECTS(res);
|
||||||
@ -168,14 +150,14 @@ int main()
|
|||||||
}
|
}
|
||||||
oFile.CloseFile();
|
oFile.CloseFile();
|
||||||
|
|
||||||
CGraphicsFileDrawing* test = XPS_Load(pXpsData, nXpsBytesCount);
|
CGraphicsFileDrawing* test = Open(pXpsData, nXpsBytesCount);
|
||||||
XPS_Delete(pXpsData);
|
RELEASEARRAYOBJECTS(pXpsData);
|
||||||
int* info = XPS_GetInfo(test);
|
int* info = GetInfo(test);
|
||||||
int pages_count = *info;
|
int pages_count = *info;
|
||||||
int width = info[1] * 96 / info[3];
|
int width = info[1] * 96 / info[3];
|
||||||
int height = info[2] * 96 / info[3];
|
int height = info[2] * 96 / info[3];
|
||||||
|
|
||||||
BYTE* pGlyphs = XPS_GetGlyphs(test, 22, width, height);
|
BYTE* pGlyphs = GetGlyphs(test, 22, width, height);
|
||||||
DWORD nLength = GetLength(pGlyphs);
|
DWORD nLength = GetLength(pGlyphs);
|
||||||
DWORD i = 4;
|
DWORD i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -209,7 +191,7 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* pLinks = XPS_GetLinks(test, 22, width, height);
|
BYTE* pLinks = GetLinks(test, 22, width, height);
|
||||||
nLength = GetLength(pLinks);
|
nLength = GetLength(pLinks);
|
||||||
i = 4;
|
i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -237,7 +219,7 @@ int main()
|
|||||||
i += nPathLength;
|
i += nPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* pStructure = XPS_GetStructure(test);
|
BYTE* pStructure = GetStructure(test);
|
||||||
nLength = GetLength(pStructure);
|
nLength = GetLength(pStructure);
|
||||||
i = 4;
|
i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -261,7 +243,7 @@ int main()
|
|||||||
|
|
||||||
BYTE* res = NULL;
|
BYTE* res = NULL;
|
||||||
if (pages_count > 0)
|
if (pages_count > 0)
|
||||||
res = XPS_GetPixmap(test, 22, width, height);
|
res = GetPixmap(test, 22, width, height);
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
std::cout << (int)res[i] << " ";
|
std::cout << (int)res[i] << " ";
|
||||||
@ -276,7 +258,7 @@ int main()
|
|||||||
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
||||||
resFrame->ClearNoAttack();
|
resFrame->ClearNoAttack();
|
||||||
|
|
||||||
XPS_Close(test);
|
Close(test);
|
||||||
RELEASEARRAYOBJECTS(info);
|
RELEASEARRAYOBJECTS(info);
|
||||||
RELEASEARRAYOBJECTS(res);
|
RELEASEARRAYOBJECTS(res);
|
||||||
RELEASEARRAYOBJECTS(pGlyphs);
|
RELEASEARRAYOBJECTS(pGlyphs);
|
||||||
@ -296,16 +278,16 @@ int main()
|
|||||||
}
|
}
|
||||||
oFile.CloseFile();
|
oFile.CloseFile();
|
||||||
|
|
||||||
CGraphicsFileDrawing* test = DJVU_Load(pDjVuData, nDjVuBytesCount);
|
CGraphicsFileDrawing* test = Open(pDjVuData, nDjVuBytesCount);
|
||||||
XPS_Delete(pDjVuData);
|
RELEASEARRAYOBJECTS(pDjVuData);
|
||||||
int* info = XPS_GetInfo(test);
|
int* info = GetInfo(test);
|
||||||
int pages_count = *info;
|
int pages_count = *info;
|
||||||
int width = info[1] * 96 / info[3];
|
int width = info[1] * 96 / info[3];
|
||||||
int height = info[2] * 96 / info[3];
|
int height = info[2] * 96 / info[3];
|
||||||
|
|
||||||
BYTE* res = NULL;
|
BYTE* res = NULL;
|
||||||
if (pages_count > 0)
|
if (pages_count > 0)
|
||||||
res = XPS_GetPixmap(test, 0, width, height);
|
res = GetPixmap(test, 0, width, height);
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
std::cout << (int)res[i] << " ";
|
std::cout << (int)res[i] << " ";
|
||||||
@ -319,7 +301,7 @@ int main()
|
|||||||
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
||||||
resFrame->ClearNoAttack();
|
resFrame->ClearNoAttack();
|
||||||
|
|
||||||
BYTE* pGlyphs = DJVU_GetGlyphs(test, 0, width, height);
|
BYTE* pGlyphs = GetGlyphs(test, 0, width, height);
|
||||||
DWORD nLength = GetLength(pGlyphs);
|
DWORD nLength = GetLength(pGlyphs);
|
||||||
DWORD i = 4;
|
DWORD i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -348,7 +330,7 @@ int main()
|
|||||||
i += nPathLength;
|
i += nPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* pLinks = DJVU_GetLinks(test, 0, width, height);
|
BYTE* pLinks = GetLinks(test, 0, width, height);
|
||||||
nLength = GetLength(pLinks);
|
nLength = GetLength(pLinks);
|
||||||
i = 4;
|
i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -376,7 +358,7 @@ int main()
|
|||||||
i += nPathLength;
|
i += nPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* pStructure = DJVU_GetStructure(test);
|
BYTE* pStructure = GetStructure(test);
|
||||||
nLength = GetLength(pStructure);
|
nLength = GetLength(pStructure);
|
||||||
i = 4;
|
i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -395,7 +377,7 @@ int main()
|
|||||||
i += nPathLength;
|
i += nPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
XPS_Close(test);
|
Close(test);
|
||||||
RELEASEARRAYOBJECTS(info);
|
RELEASEARRAYOBJECTS(info);
|
||||||
RELEASEARRAYOBJECTS(res);
|
RELEASEARRAYOBJECTS(res);
|
||||||
RELEASEARRAYOBJECTS(pGlyphs);
|
RELEASEARRAYOBJECTS(pGlyphs);
|
||||||
70
DesktopEditor/graphics/pro/js/wasm/src/drawingfile.h
Normal file
70
DesktopEditor/graphics/pro/js/wasm/src/drawingfile.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#ifndef _WASM_GRAPHICS_
|
||||||
|
#define _WASM_GRAPHICS_
|
||||||
|
|
||||||
|
#include "../../../../GraphicsRenderer.h"
|
||||||
|
#include "../../../../pro/Graphics.h"
|
||||||
|
#include "../../../../../common/officedrawingfile.h"
|
||||||
|
#include "../../../../../../XpsFile/XpsFile.h"
|
||||||
|
#include "../../../../../../DjVuFile/DjVu.h"
|
||||||
|
#include "../../../../../../PdfReader/PdfReader.h"
|
||||||
|
|
||||||
|
class CGraphicsFileDrawing
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
IOfficeDrawingFile* pReader;
|
||||||
|
NSFonts::IApplicationFonts* pApplicationFonts;
|
||||||
|
public:
|
||||||
|
CGraphicsFileDrawing()
|
||||||
|
{
|
||||||
|
pReader = NULL;
|
||||||
|
pApplicationFonts = NSFonts::NSApplication::Create();
|
||||||
|
}
|
||||||
|
~CGraphicsFileDrawing()
|
||||||
|
{
|
||||||
|
RELEASEOBJECT(pReader);
|
||||||
|
RELEASEOBJECT(pApplicationFonts);
|
||||||
|
}
|
||||||
|
bool Open (BYTE* data, DWORD length, int nType)
|
||||||
|
{
|
||||||
|
if (nType == 0)
|
||||||
|
pReader = new PdfReader::CPdfReader(pApplicationFonts);
|
||||||
|
else if (nType == 1)
|
||||||
|
pReader = new CDjVuFile(pApplicationFonts);
|
||||||
|
else if (nType == 2)
|
||||||
|
pReader = new CXpsFile(pApplicationFonts);
|
||||||
|
if (!pReader)
|
||||||
|
return false;
|
||||||
|
return pReader->LoadFromMemory(data, length);
|
||||||
|
}
|
||||||
|
int GetPagesCount()
|
||||||
|
{
|
||||||
|
return pReader->GetPagesCount();
|
||||||
|
}
|
||||||
|
void GetPageInfo (int nPageIndex, int& nWidth, int& nHeight, int& nPageDpiX)
|
||||||
|
{
|
||||||
|
double dPageDpiX, dPageDpiY;
|
||||||
|
double dWidth, dHeight;
|
||||||
|
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||||
|
nWidth = dWidth;
|
||||||
|
nHeight = dHeight;
|
||||||
|
nPageDpiX = dPageDpiX;
|
||||||
|
}
|
||||||
|
BYTE* GetPage (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return pReader->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true);
|
||||||
|
}
|
||||||
|
BYTE* GetGlyphs (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return pReader->GetGlyphs(nPageIndex, nRasterW, nRasterH);
|
||||||
|
}
|
||||||
|
BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return pReader->GetLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
|
}
|
||||||
|
BYTE* GetStructure()
|
||||||
|
{
|
||||||
|
return pReader->GetStructure();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WASM_GRAPHICS_
|
||||||
@ -1,94 +0,0 @@
|
|||||||
#ifndef _WASM_GRAPHICS_
|
|
||||||
#define _WASM_GRAPHICS_
|
|
||||||
|
|
||||||
#include "../../../../GraphicsRenderer.h"
|
|
||||||
#include "../../../../pro/Graphics.h"
|
|
||||||
#include "../../../../../common/officedrawingfile.h"
|
|
||||||
#include "../../../../../../XpsFile/XpsFile.h"
|
|
||||||
#include "../../../../../../DjVuFile/DjVu.h"
|
|
||||||
#include "../../../../../../PdfReader/PdfReader.h"
|
|
||||||
|
|
||||||
class CGraphicsFileDrawing
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
IOfficeDrawingFile* pReader;
|
|
||||||
NSFonts::IApplicationFonts* pApplicationFonts;
|
|
||||||
public:
|
|
||||||
CGraphicsFileDrawing()
|
|
||||||
{
|
|
||||||
pApplicationFonts = NSFonts::NSApplication::Create();
|
|
||||||
}
|
|
||||||
~CGraphicsFileDrawing()
|
|
||||||
{
|
|
||||||
RELEASEOBJECT(pReader);
|
|
||||||
RELEASEOBJECT(pApplicationFonts);
|
|
||||||
}
|
|
||||||
void CreateXPS()
|
|
||||||
{
|
|
||||||
pReader = new CXpsFile(pApplicationFonts);
|
|
||||||
}
|
|
||||||
void CreateDjVu()
|
|
||||||
{
|
|
||||||
pReader = new CDjVuFile(pApplicationFonts);
|
|
||||||
}
|
|
||||||
void CreatePDF()
|
|
||||||
{
|
|
||||||
pReader = new PdfReader::CPdfReader(pApplicationFonts);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadFromMemory(BYTE* data, DWORD length)
|
|
||||||
{
|
|
||||||
return pReader->LoadFromMemory(data, length);
|
|
||||||
}
|
|
||||||
int GetPagesCount()
|
|
||||||
{
|
|
||||||
return pReader->GetPagesCount();
|
|
||||||
}
|
|
||||||
void GetPageInfo (int nPageIndex, int& nWidth, int& nHeight, int& nPageDpiX)
|
|
||||||
{
|
|
||||||
double dPageDpiX, dPageDpiY;
|
|
||||||
double dWidth, dHeight;
|
|
||||||
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
|
||||||
nWidth = dWidth;
|
|
||||||
nHeight = dHeight;
|
|
||||||
nPageDpiX = dPageDpiX;
|
|
||||||
}
|
|
||||||
BYTE* GetPage (int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
BYTE* flipped = pReader->ConvertToPixels(nPageIndex, nRasterW, nRasterH);
|
|
||||||
BYTE* pixmap_cur = flipped;
|
|
||||||
for (int j = nRasterH - 1; j >= nRasterH / 2; --j)
|
|
||||||
{
|
|
||||||
BYTE* pLine = flipped + (j * nRasterW * 4);
|
|
||||||
std::swap_ranges(pixmap_cur, pixmap_cur + nRasterW * 4, pLine);
|
|
||||||
pixmap_cur += nRasterW * 4;
|
|
||||||
}
|
|
||||||
return flipped;
|
|
||||||
}
|
|
||||||
BYTE* GetXPSGlyphs (int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
return ((CXpsFile*)pReader)->GetGlyphs(nPageIndex, nRasterW, nRasterH);
|
|
||||||
}
|
|
||||||
BYTE* GetDJVUGlyphs(int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
return ((CDjVuFile*)pReader)->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
|
|
||||||
}
|
|
||||||
BYTE* GetXPSLinks (int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
return ((CXpsFile*)pReader)->GetLinks(nPageIndex, nRasterW, nRasterH);
|
|
||||||
}
|
|
||||||
BYTE* GetDJVULinks (int nPageIndex, int nRasterW, int nRasterH)
|
|
||||||
{
|
|
||||||
return ((CDjVuFile*)pReader)->GetPageLinks(nPageIndex, nRasterW, nRasterH);
|
|
||||||
}
|
|
||||||
BYTE* GetXPSStructure()
|
|
||||||
{
|
|
||||||
return ((CXpsFile*)pReader)->GetStructure();
|
|
||||||
}
|
|
||||||
BYTE* GetDJVUStructure()
|
|
||||||
{
|
|
||||||
return ((CDjVuFile*)pReader)->GetStructure();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _WASM_GRAPHICS_
|
|
||||||
@ -89,10 +89,10 @@ void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* p
|
|||||||
if (m_pImplementation)
|
if (m_pImplementation)
|
||||||
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
|
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
|
||||||
}
|
}
|
||||||
BYTE* CDjVuFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
BYTE* CDjVuFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
|
||||||
{
|
{
|
||||||
if (m_pImplementation)
|
if (m_pImplementation)
|
||||||
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH);
|
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH, bIsFlip);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
|
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
|
||||||
@ -112,13 +112,13 @@ BYTE* CDjVuFile::GetStructure()
|
|||||||
return m_pImplementation->GetStructure();
|
return m_pImplementation->GetStructure();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
BYTE* CDjVuFile::GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH)
|
BYTE* CDjVuFile::GetGlyphs(int nPageIndex, int nRasterW, int nRasterH)
|
||||||
{
|
{
|
||||||
if (m_pImplementation)
|
if (m_pImplementation)
|
||||||
return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
|
return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
BYTE* CDjVuFile::GetPageLinks (int nPageIndex, int nRasterW, int nRasterH)
|
BYTE* CDjVuFile::GetLinks (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
{
|
{
|
||||||
if (m_pImplementation)
|
if (m_pImplementation)
|
||||||
return m_pImplementation->GetPageLinks(nPageIndex, nRasterW, nRasterH);
|
return m_pImplementation->GetPageLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
|
|||||||
@ -67,13 +67,13 @@ public:
|
|||||||
virtual int GetPagesCount();
|
virtual int GetPagesCount();
|
||||||
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||||
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||||
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
|
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);
|
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
|
||||||
|
|
||||||
void ConvertToPdf(const std::wstring& path);
|
void ConvertToPdf(const std::wstring& path);
|
||||||
#ifdef WASM_MODE
|
#ifdef BUILDING_WASM_MODULE
|
||||||
BYTE* GetStructure();
|
virtual BYTE* GetStructure();
|
||||||
BYTE* GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
||||||
BYTE* GetPageLinks (int nPageIndex, int nRasterW, int nRasterH);
|
virtual BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@ -223,7 +223,7 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
|
|||||||
// белая страница
|
// белая страница
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, const int& nRasterW, const int& nRasterH)
|
BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, const int& nRasterW, const int& nRasterH, bool bIsFlip)
|
||||||
{
|
{
|
||||||
if (!m_pApplicationFonts)
|
if (!m_pApplicationFonts)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -252,7 +252,7 @@ BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, cons
|
|||||||
oFrame.put_Data(pBgraData);
|
oFrame.put_Data(pBgraData);
|
||||||
oFrame.put_Width(nWidth);
|
oFrame.put_Width(nWidth);
|
||||||
oFrame.put_Height(nHeight);
|
oFrame.put_Height(nHeight);
|
||||||
oFrame.put_Stride(-4 * nWidth);
|
oFrame.put_Stride((bIsFlip ? 4 : -4) * nWidth);
|
||||||
|
|
||||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||||
pRenderer->SetSwapRGB(true);
|
pRenderer->SetSwapRGB(true);
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public:
|
|||||||
int GetPagesCount() const;
|
int GetPagesCount() const;
|
||||||
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
|
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
|
||||||
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||||
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1);
|
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1, bool bIsFlip = false);
|
||||||
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
|
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
|
||||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||||
#ifdef WASM_MODE
|
#ifdef WASM_MODE
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
var data = new Uint8Array(arrayBuffer);
|
var data = new Uint8Array(arrayBuffer);
|
||||||
var _stream = Module["_malloc"](data.length);
|
var _stream = Module["_malloc"](data.length);
|
||||||
Module["HEAP8"].set(data, _stream);
|
Module["HEAP8"].set(data, _stream);
|
||||||
this.nativeFile = Module["_DJVU_Load"](_stream, data.length);
|
this.nativeFile = Module["_Open"](_stream, data.length);
|
||||||
Module["_free"](_stream);
|
Module["_free"](_stream);
|
||||||
return this.getInfo();
|
return this.getInfo();
|
||||||
};
|
};
|
||||||
@ -106,7 +106,7 @@
|
|||||||
if (!this.nativeFile)
|
if (!this.nativeFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var _info = Module["_XPS_GetInfo"](this.nativeFile);
|
var _info = Module["_GetInfo"](this.nativeFile);
|
||||||
if (!_info)
|
if (!_info)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -124,11 +124,11 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
return Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
|
||||||
};
|
};
|
||||||
CFile.prototype.getGlyphs = function(pageIndex, width, height)
|
CFile.prototype.getGlyphs = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
var glyphs = Module["_DJVU_GetGlyphs"](this.nativeFile, pageIndex, width, height);
|
var glyphs = Module["_GetGlyphs"](this.nativeFile, pageIndex, width, height);
|
||||||
if (glyphs == null)
|
if (glyphs == null)
|
||||||
return;
|
return;
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
|
||||||
@ -176,12 +176,12 @@
|
|||||||
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
|
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
|
||||||
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
|
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
|
||||||
}
|
}
|
||||||
Module["_XPS_Delete"](glyphs);
|
Module["_free"](glyphs);
|
||||||
};
|
};
|
||||||
CFile.prototype.getLinks = function(pageIndex, width, height)
|
CFile.prototype.getLinks = function(pageIndex, width, height)
|
||||||
{
|
{
|
||||||
var res = [];
|
var res = [];
|
||||||
var ext = Module["_DJVU_GetLinks"](this.nativeFile, pageIndex, width, height);
|
var ext = Module["_GetLinks"](this.nativeFile, pageIndex, width, height);
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
|
||||||
if (lenArray == null)
|
if (lenArray == null)
|
||||||
return res;
|
return res;
|
||||||
@ -218,13 +218,13 @@
|
|||||||
res.push({ X : _X, Y : _Y, W : _W, H : _H, Link : _Link});
|
res.push({ X : _X, Y : _Y, W : _W, H : _H, Link : _Link});
|
||||||
}
|
}
|
||||||
|
|
||||||
Module["_XPS_Delete"](ext);
|
Module["_free"](ext);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
CFile.prototype.structure = function()
|
CFile.prototype.structure = function()
|
||||||
{
|
{
|
||||||
var res = [];
|
var res = [];
|
||||||
var str = Module["_DJVU_GetStructure"](this.nativeFile);
|
var str = Module["_GetStructure"](this.nativeFile);
|
||||||
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
|
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
|
||||||
if (lenArray == null)
|
if (lenArray == null)
|
||||||
return res;
|
return res;
|
||||||
@ -253,12 +253,12 @@
|
|||||||
res.push({ page : _Page, level : _Level, Y : 0, description : _Description});
|
res.push({ page : _Page, level : _Level, Y : 0, description : _Description});
|
||||||
}
|
}
|
||||||
|
|
||||||
Module["_XPS_Delete"](str);
|
Module["_free"](str);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
CFile.prototype.close = function()
|
CFile.prototype.close = function()
|
||||||
{
|
{
|
||||||
Module["_XPS_Close"](this.nativeFile);
|
Module["_Close"](this.nativeFile);
|
||||||
this.nativeFile = 0;
|
this.nativeFile = 0;
|
||||||
this.pages = [];
|
this.pages = [];
|
||||||
};
|
};
|
||||||
@ -268,7 +268,7 @@
|
|||||||
};
|
};
|
||||||
CFile.prototype.free = function(pointer)
|
CFile.prototype.free = function(pointer)
|
||||||
{
|
{
|
||||||
Module["_XPS_Delete"](pointer);
|
Module["_free"](pointer);
|
||||||
};
|
};
|
||||||
|
|
||||||
window["AscViewer"].DjVuFile = CFile;
|
window["AscViewer"].DjVuFile = CFile;
|
||||||
|
|||||||
@ -14,11 +14,11 @@ base.create_dir("./deploy")
|
|||||||
base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["make.py"])
|
base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["make.py"])
|
||||||
|
|
||||||
# finalize
|
# finalize
|
||||||
if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/xps_djvu_pdf.wasm"):
|
if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm"):
|
||||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.js", "./deploy/xps.js")
|
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.js", "./deploy/xps.js")
|
||||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/djvu.js", "./deploy/djvu.js")
|
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/djvu.js", "./deploy/djvu.js")
|
||||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/pdf.js", "./deploy/pdf.js")
|
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/pdf.js", "./deploy/pdf.js")
|
||||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps_djvu_pdf.wasm", "./deploy/xps_djvu_pdf.wasm")
|
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm", "./deploy/drawingfile.wasm")
|
||||||
else:
|
else:
|
||||||
print("make.py error")
|
print("make.py error")
|
||||||
base.copy_dir("./all_files_test/xps_djvu", "./deploy")
|
base.copy_dir("./all_files_test/xps_djvu", "./deploy")
|
||||||
|
|||||||
@ -288,7 +288,7 @@ namespace PdfReader
|
|||||||
m_pInternal->m_pPDFDocument->DisplayPage(&oRendererOut, nPageIndex, 72.0, 72.0, 0, false, true, false);
|
m_pInternal->m_pPDFDocument->DisplayPage(&oRendererOut, nPageIndex, 72.0, 72.0, 0, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BYTE* CPdfReader::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
BYTE* CPdfReader::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
|
||||||
{
|
{
|
||||||
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||||
@ -314,7 +314,7 @@ namespace PdfReader
|
|||||||
oFrame.put_Data(pBgraData);
|
oFrame.put_Data(pBgraData);
|
||||||
oFrame.put_Width(nWidth);
|
oFrame.put_Width(nWidth);
|
||||||
oFrame.put_Height(nHeight);
|
oFrame.put_Height(nHeight);
|
||||||
oFrame.put_Stride(-4 * nWidth);
|
oFrame.put_Stride((bIsFlip ? 4 : -4) * nWidth);
|
||||||
|
|
||||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||||
pRenderer->SetSwapRGB(true);
|
pRenderer->SetSwapRGB(true);
|
||||||
@ -449,4 +449,18 @@ namespace PdfReader
|
|||||||
|
|
||||||
return wsXml;
|
return wsXml;
|
||||||
}
|
}
|
||||||
|
#ifdef BUILDING_WASM_MODULE
|
||||||
|
BYTE* CPdfReader::GetStructure()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
BYTE* CPdfReader::GetGlyphs(int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
BYTE* CPdfReader::GetLinks (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ namespace PdfReader
|
|||||||
virtual int GetPagesCount();
|
virtual int GetPagesCount();
|
||||||
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||||
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||||
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
|
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);
|
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
|
||||||
|
|
||||||
EError GetError();
|
EError GetError();
|
||||||
@ -81,6 +81,11 @@ namespace PdfReader
|
|||||||
NSFonts::IFontManager* GetFontManager();
|
NSFonts::IFontManager* GetFontManager();
|
||||||
|
|
||||||
std::wstring ToXml(const std::wstring& wsXmlPath);
|
std::wstring ToXml(const std::wstring& wsXmlPath);
|
||||||
|
#ifdef BUILDING_WASM_MODULE
|
||||||
|
virtual BYTE* GetStructure();
|
||||||
|
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
||||||
|
virtual BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPdfReader_Private* m_pInternal;
|
CPdfReader_Private* m_pInternal;
|
||||||
|
|||||||
@ -169,7 +169,7 @@ void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pB
|
|||||||
|
|
||||||
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak, nLastW, nLastH);
|
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak, nLastW, nLastH);
|
||||||
}
|
}
|
||||||
BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
|
||||||
{
|
{
|
||||||
nLastW = nRasterW, nLastH = nRasterH;
|
nLastW = nRasterW, nLastH = nRasterH;
|
||||||
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||||
@ -196,7 +196,7 @@ BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
|||||||
oFrame.put_Data(pBgraData);
|
oFrame.put_Data(pBgraData);
|
||||||
oFrame.put_Width(nWidth);
|
oFrame.put_Width(nWidth);
|
||||||
oFrame.put_Height(nHeight);
|
oFrame.put_Height(nHeight);
|
||||||
oFrame.put_Stride(-4 * nWidth);
|
oFrame.put_Stride((bIsFlip ? 4 : -4) * nWidth);
|
||||||
|
|
||||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||||
pRenderer->SetSwapRGB(true);
|
pRenderer->SetSwapRGB(true);
|
||||||
|
|||||||
@ -62,14 +62,14 @@ public:
|
|||||||
virtual int GetPagesCount();
|
virtual int GetPagesCount();
|
||||||
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||||
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||||
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
|
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);
|
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
|
||||||
|
|
||||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||||
#ifdef BUILDING_WASM_MODULE
|
#ifdef BUILDING_WASM_MODULE
|
||||||
BYTE* GetStructure();
|
virtual BYTE* GetStructure();
|
||||||
BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
||||||
BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
|
virtual BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user