当前位置:   article > 正文

onlyoffice支持wps、dps和et格式的预览和编辑,支持office2003版本的编辑, 增加中文字体,字号_onlyoffice添加中文字体

onlyoffice添加中文字体

一、支持wps、dps和et格式的预览和编辑,支持office2003版本的编辑

onlyoffice的版本为7.2.2

1、修改documentserver,进入docker容器

docker exec -it onlyoffice-server bash
  • 1

进入 /var/www/onlyoffice/documentserver/web-apps/apps/api/documents/ 目录,在api.js中以下两处添加添加wps、et和dps

cd /var/www/onlyoffice/documentserver/web-apps/apps/api/documents/
vim api.js
  • 1
  • 2
var appMap = {
      'text': 'docx',
      'text-pdf': 'pdf',
      'spreadsheet': 'xlsx',
      'presentation': 'pptx',
      'word': 'docx',
      'cell': 'xlsx',
      'slide': 'pptx',
      'wps': 'docx',
      'et': 'xlsx',
      'dps': 'pptx'
  }, app;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb|et)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp|dps)|(doc|docx|doct|odt|gdoc|txt|rtf|pdf|mht|htm|html|epub|djvu|xps|oxps|docm|dot|dotm|dotx|fodt|ott|fb2|xml|oform|docxf|wps))$/
                                    .exec(_config.document.fileType);
  • 1
  • 2
删掉api.js.gz文件
rm -rf api.js.gz
  • 1

2、修改onlyoffice源码

修改配置文件代码,config.py

import os

FILE_SIZE_MAX = 5242880
STORAGE_PATH = 'app_data'
DOC_FOLDER = "doc"

DOC_SERV_VIEWED = [".pdf", ".djvu", ".xps"]
DOC_SERV_EDITED = [".docx", ".xlsx", ".csv", ".pptx", ".txt", ".wps", ".xls", ".doc", ".dps", ".et"]
DOC_SERV_CONVERT = [
    ".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt",
    ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm",
    ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt",
    ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot",
    ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub"
]

DOC_SERV_TIMEOUT = 120000

DOC_SERV_CONVERTER_URL = 'http://0.0.0.0:9880/ConvertService.ashx'
DOC_SERV_API_URL = 'http://0.0.0.0:9880/web-apps/apps/api/documents/api.js'
DOC_SERV_PRELOADER_URL = 'http://0.0.0.0:9880/web-apps/apps/api/documents/cache-scripts.html'

EXAMPLE_DOMAIN = 'http://0.0.0.0:8000/'

DOC_SERV_JWT_SECRET = 'rtf_jwt_secret'


EXT_SPREADSHEET = [
    ".xls", ".xlsx", ".xlsm",
    ".xlt", ".xltx", ".xltm",
    ".ods", ".fods", ".ots", ".csv", ".et"
]

EXT_PRESENTATION = [
    ".pps", ".ppsx", ".ppsm",
    ".ppt", ".pptx", ".pptm",
    ".pot", ".potx", ".potm",
    ".odp", ".fodp", ".otp", ".dps"
]

EXT_DOCUMENT = [
    ".doc", ".docx", ".docm",
    ".dot", ".dotx", ".dotm",
    ".odt", ".fodt", ".ott", ".rtf", ".txt",
    ".html", ".htm", ".mht",
    ".pdf", ".djvu", ".fb2", ".epub", ".xps", "wps"
]


if os.environ.get("EXAMPLE_DOMAIN"):
    EXAMPLE_DOMAIN = os.environ.get("EXAMPLE_DOMAIN")
    
if os.environ.get("DOC_SERV"):
    base = os.environ.get("DOC_SERV").rstrip('/')
    DOC_SERV_CONVERTER_URL = base + '/ConvertService.ashx'
    DOC_SERV_API_URL = base + '/web-apps/apps/api/documents/api.js'
    DOC_SERV_PRELOADER_URL = base + '/web-apps/apps/api/documents/cache-scripts.html'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

二、中文字体设置

进入容器
docker exec -it onlyoffice-server bash
  • 1
删除自带字体
cd /var/www/onlyoffice/documentserver/core-fonts/     
rm -rf *
  • 1
  • 2
退出docker容器
exit
  • 1
将字体复制到/var/www/onlyoffice/documentserver/core-fonts/文件夹下
docker cp /home/Fonts onlyoffice-server:/var/www/onlyoffice/documentserver/core-fonts/
  • 1
进入到docker容器 :
docker exec -it onlyoffice-server bash
  • 1
在docker容器里执行命令:
 /usr/bin/documentserver-generate-allfonts.sh
  • 1
退出docker容器
 exit
  • 1
重启docker镜像:
docker restart onlyoffice-server
  • 1

三、中文字号添加

进入容器
docker exec -it onlyoffice-server bash
  • 1
使用vim编辑app.js文件
vim /var/www/onlyoffice/documentserver/web-apps/apps/documenteditor/main/app.js 
  • 1
找到{value:8,displayValue:“8”}这个位置, 在前面添加以下字号
{value:42,displayValue:"初号"},
{value:36,displayValue:"小初"},
{value:26,displayValue:"一号"},
{value:24,displayValue:"小一"},
{value:22,displayValue:"二号"},
{value:18,displayValue:"小二"},
{value:16,displayValue:"三号"},
{value:15,displayValue:"小三"},
{value:14,displayValue:"四号"},
{value:12,displayValue:"小四"},
{value:10.5,displayValue:"五号"},
{value:9,displayValue:"小五"},
{value:7.5,displayValue:"六号"},
{value:6.5,displayValue:"小六"},
{value:5.5,displayValue:"七号"},
{value:5,displayValue:"八号"},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
删除app.js.gz文件
rm -rf app.js.gz
  • 1
退出docker容器
 exit
  • 1
重启docker镜像:
docker restart onlyoffice-server
  • 1

注意:测试时清除本地缓存

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号