Compare commits

...

6 Commits

11 changed files with 79 additions and 4 deletions

2
.gitmodules vendored
View File

@ -5,7 +5,7 @@
[submodule "web/documentserver-example/nodejs/public/assets/document-formats"]
path = web/documentserver-example/nodejs/public/assets/document-formats
url = https://github.com/ONLYOFFICE/document-formats
branch = master
branch = feature/v8.0
[submodule "web/documentserver-example/csharp-mvc/assets/document-templates"]
path = web/documentserver-example/csharp-mvc/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates

View File

@ -1,5 +1,7 @@
# Change Log
- nodejs: pdf, djvu, xps, oxps as pdf documentType
- nodejs: filling pdf
- version number to page meta
- sr-Latn-CS skin languages
- getting history via api

View File

@ -994,19 +994,30 @@ app.get('/editor', (req, res) => { // define a handler for editing document
if (!canEdit && mode === 'edit') {
mode = 'view';
}
const submitForm = mode === 'fillForms' && userid === 'uid-1';
const ext = fileUtility.getFileExtension(fileName, true);
let isForm = 'null';
if (!req.query.checkform && ext === 'pdf') {
isForm = req.DocManager.isExtendedPDFFile(fileName);
}
let submitForm = false;
if (mode === 'fillForms') {
submitForm = userid === 'uid-1';
}
// file config data
const argss = {
apiUrl: siteUrl + configServer.get('apiUrl'),
file: {
name: fileName,
ext: fileUtility.getFileExtension(fileName, true),
ext: ext,
uri: url,
directUrl: !userDirectUrl ? null : directUrl,
uriUser: directUrl,
created: new Date().toDateString(),
favorite: user.favorite != null ? user.favorite : 'null',
isForm: isForm,
},
editor: {
type,

View File

@ -26,6 +26,7 @@
"storagePath": "/files",
"maxFileSize": 1073741824,
"maxNameLength": 50,
"gFormatOformPdfMetaTag": "ONLYOFFICEFORM",
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
"token": {
"enable": false,

View File

@ -606,6 +606,59 @@ DocManager.prototype.getFilesInfo = function getFilesInfo(fileId) {
} return responseArray;
};
DocManager.prototype.isExtendedPDFFile = function isExtendedPDFFile(fileName) {
let filePath = this.forcesavePath(fileName, null, false);
if (filePath === '') {
filePath = this.storagePath(fileName);
}
const bufferSize = 110;
const buffer = Buffer.alloc(bufferSize);
const fd = fileSystem.openSync(filePath, 'r');
fileSystem.readSync(fd, buffer, 0, bufferSize);
fileSystem.closeSync(fd);
const pBuffer = buffer.toString('latin1');
const indexFirst = pBuffer.indexOf('%\xCD\xCA\xD2\xA9\x0D');
if (indexFirst === -1) {
return false;
}
let pFirst = pBuffer.substring(indexFirst + 6);
if (!pFirst.startsWith('1 0 obj\x0A<<\x0A')) {
return false;
}
pFirst = pFirst.substring(11);
const indexStream = pFirst.indexOf('stream\x0D\x0A');
const indexMeta = pFirst.indexOf(configServer.get('gFormatOformPdfMetaTag'));
if (indexStream === -1 || indexMeta === -1 || indexStream < indexMeta) {
return false;
}
let pMeta = pFirst.substring(indexMeta);
pMeta = pMeta.substring(configServer.get('gFormatOformPdfMetaTag').length + 3);
let indexMetaLast = pMeta.indexOf(' ');
if (indexMetaLast === -1) {
return false;
}
pMeta = pMeta.substring(indexMetaLast + 1);
indexMetaLast = pMeta.indexOf(' ');
if (indexMetaLast === -1) {
return false;
}
return true;
};
DocManager.prototype.getInstanceId = function getInstanceId() {
return this.getServerUrl();
};

View File

@ -64,6 +64,7 @@ fileUtility.fileType = {
word: 'word',
cell: 'cell',
slide: 'slide',
pdf: 'pdf',
};
fileUtility.getSuppotredExtensions = function getSuppotredExtensions() {

View File

@ -0,0 +1 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 1h8l4 4v10H2V1z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14 5l-4-4H2v14h12V5zm-4-5l5 5v11H1V0h9z" fill="#BFBFBF"/><path fill="#9E1919" d="M3 10h10v4H3z"/><path d="M7 7V2H3v5h4zM8 3V2h2v1H8zM8 5V4h5v1H8zM13 6H8v1h5V6zM13 8H3v1h10V8z" fill="#BFBFBF"/><path opacity=".3" d="M9 1h1v3h4l1 1H9V1z" fill="#333"/></svg>

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -470,6 +470,11 @@ footer table tr td:first-child {
background-image: url("../images/icon_pptx.svg");
}
.stored-edit.pdf,
.uploadFileName.pdf {
background-image: url("../images/icon_pdf.svg");
}
.stored-edit span {
font-size: 12px;
line-height: 12px;

View File

@ -6,6 +6,7 @@
"uploaded": "<%- file.created %>",
"favorite": <%- file.favorite %>
},
"isForm": <%- file.isForm %>,
"key": "<%- editor.key %>",
"permissions": {
"chat": <%- editor.chat %>,