mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 00:03:33 +08:00
pdf fix links
This commit is contained in:
@ -123,8 +123,10 @@
|
||||
{
|
||||
this.nativeFile = 0;
|
||||
this.stream = -1;
|
||||
this.stream_size = 0;
|
||||
this.type = -1;
|
||||
this.pages = [];
|
||||
this._isNeedPassword = false;
|
||||
}
|
||||
|
||||
CFile.prototype["loadFromData"] = function(arrayBuffer)
|
||||
@ -132,21 +134,44 @@
|
||||
var data = new Uint8Array(arrayBuffer);
|
||||
var _stream = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, _stream);
|
||||
this.nativeFile = Module["_Open"](_stream, data.length);
|
||||
var nCodeError = Module["_GetErrorCode"](this.nativeFile);
|
||||
// 4 - нужен пароль
|
||||
if (nCodeError == 4)
|
||||
return null;
|
||||
// 0 - ошибки нет
|
||||
if (nCodeError != 0)
|
||||
{
|
||||
this.close();
|
||||
return null;
|
||||
}
|
||||
this.nativeFile = Module["_Open"](_stream, data.length, 0);
|
||||
var error = Module["_GetErrorCode"](this.nativeFile);
|
||||
this.stream = _stream;
|
||||
this.stream_size = data.length;
|
||||
this.type = Module["_GetType"](_stream, data.length);
|
||||
self.drawingFile = this;
|
||||
return this.getInfo();
|
||||
this.getInfo();
|
||||
this._isNeedPassword = (4 === error) ? true : false;
|
||||
|
||||
// 0 - ok
|
||||
// 4 - password
|
||||
// else - error
|
||||
return error;
|
||||
};
|
||||
CFile.prototype["loadFromDataWithPassword"] = function(password)
|
||||
{
|
||||
if (0 != this.nativeFile)
|
||||
Module["_Close"](this.nativeFile);
|
||||
|
||||
var passBuffer = password.toUtf8();
|
||||
var passPointer = Module["_malloc"](passBuffer.length);
|
||||
Module["HEAP8"].set(passBuffer, passPointer);
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passPointer);
|
||||
Module["_free"](passPointer);
|
||||
var error = Module["_GetErrorCode"](this.nativeFile);
|
||||
this.type = Module["_GetType"](this.stream, this.stream_size);
|
||||
self.drawingFile = this;
|
||||
this.getInfo();
|
||||
this._isNeedPassword = (4 === error) ? true : false;
|
||||
|
||||
// 0 - ok
|
||||
// 4 - password
|
||||
// else - error
|
||||
return error;
|
||||
};
|
||||
CFile.prototype["isNeedPassword"] = function()
|
||||
{
|
||||
return this._isNeedPassword;
|
||||
};
|
||||
CFile.prototype["getInfo"] = function()
|
||||
{
|
||||
|
||||
@ -149,14 +149,14 @@ static DWORD GetLength(BYTE* x)
|
||||
|
||||
int main()
|
||||
{
|
||||
#define XPS_TEST 1
|
||||
#define XPS_TEST 0
|
||||
#define DJVU_TEST 0
|
||||
#define PDF_TEST 0
|
||||
#define PDF_TEST 1
|
||||
#if PDF_TEST
|
||||
BYTE* pPdfData = NULL;
|
||||
DWORD nPdfBytesCount;
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test2.pdf", &pPdfData, nPdfBytesCount))
|
||||
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.pdf", &pPdfData, nPdfBytesCount))
|
||||
{
|
||||
RELEASEARRAYOBJECTS(pPdfData);
|
||||
return 1;
|
||||
@ -181,7 +181,7 @@ int main()
|
||||
}
|
||||
int* info = GetInfo(test);
|
||||
int pages_count = *info;
|
||||
int test_page = 0;
|
||||
int test_page = 1;
|
||||
int width = info[test_page * 3 + 1];
|
||||
int height = info[test_page * 3 + 2];
|
||||
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
|
||||
|
||||
@ -652,7 +652,11 @@ return 0;
|
||||
if (!sLink)
|
||||
continue;
|
||||
std::string link(sLink->getCString(), sLink->getLength());
|
||||
size_t find = link.find("http");
|
||||
size_t find = link.find("http://");
|
||||
if (find == std::string::npos)
|
||||
find = link.find("https://");
|
||||
if (find == std::string::npos)
|
||||
find = link.find("www.");
|
||||
if (find != std::string::npos)
|
||||
{
|
||||
link.erase(0, find);
|
||||
|
||||
Reference in New Issue
Block a user