Dear OnlyOffice Support Team,
First of all, I apologize for the screenshots containing Chinese content.
Currently, I have successfully embedded the OnlyOffice editor into a web page hosted on my own server. However, I encountered a problem when trying to enable the version history feature.
The generated token validated correctly on JWT:
{
"document": {
"fileType": "docx",
"key": "599e49dad07d44129668cb2d32fc61aa",
"title": "F-AD-2-10B_文件用印申請單.docx",
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=599e49dad07d44129668cb2d32fc61aa&v=F-AD-2-10B_文件用印申請單_20250604144500.docx"
},
"documentType": "word",
"editorConfig": {
"mode": "edit",
"lang": "zh-TW",
"callbackUrl": "http://172.20.10.5:54315/Handler/SaveCallback.aspx",
"canUseHistory": true,
"customization": {
"forcesave": true,
"autosave": true,
"trackChanges": true,
"buttons": {
"print": false,
"download": false
}
},
"user": {
"id": "DEB9B207-9194-4029-8184-39AE154F58A1",
"name": "林素玉"
},
"history": {
"currentVersion": 1,
"data": [
{
"version": 1,
"key": "599e49dad07d44129668cb2d32fc61aa",
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=599e49dad07d44129668cb2d32fc61aa&v=F-AD-2-10B_文件用印申請單_20250604144500.docx",
"created": "2025-06-04T06:21:34Z",
"user": {
"id": "DEB9B207-9194-4029-8184-39AE154F58A1",
"name": "林素玉"
}
},
{
"version": 2,
"key": "ver2-599e49dad07d44129668cb2d32fc61aa",
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=599e49dad07d44129668cb2d32fc61aa&v=F-AD-2-10B_文件用印申請單_20250604145427.docx",
"created": "2025-06-05T06:21:34Z",
"user": {
"id": "DEB9B207-9194-4029-8184-39AE154F58A1",
"name": "林素玉"
}
}
]
}
},
"permissions": {
"edit": true,
"review": true,
"comment": true,
"print": false,
"download": false
},
"height": "100%",
"width": "100%",
"type": "desktop"
}
We are using the Enterprise Edition that you provide with a 30-day trial license, and I have confirmed that the license file has been correctly placed in the Document Server.
Here is the function I’m using on the frontend with the DocsAPI.DocEditor
function getData() {
$.ajax({
type: "POST",
async: false, //在沒有返回值之前,不會執行下一步動作
url: "../Handler/GetFile.aspx",
data: {
guid: $.getQueryString("fguid"),
filetype: "data",
type: "17"
},
error: function (xhr) {
alert("Error: " + xhr.status);
console.log(xhr.responseText);
},
success: function (data) {
if ($(data).find("Error").length > 0) {
alert($(data).find("Error").attr("Message"));
}
else {
if ($(data).find("data_item").length > 0) {
$(data).find("data_item").each(function (i) {
console.log("後端回傳檔案名:", $("fileName", data).text());
const fileName = $("fileName", data).text();
const fileNewName = $("fileNewName", data).text();
const authToken = $("token", data).text();
const onlyofficeguid = $("onlyofficeguid", data).text();
const mGuid = $("mGuid", data).text();
const mName = $("mName", data).text();
localStorage.setItem('authToken', authToken);
console.log("Initializing OnlyOffice Viewer for:", fileName, "\rToken:", authToken);
var editorConfig = {
"document": {
"fileType": "docx",
"key": onlyofficeguid,
"title": fileName,
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + onlyofficeguid +"&v=" + encodeURIComponent(fileNewName)
},
"documentType": "word",
"editorConfig": {
"mode": "edit",
"lang": "zh-TW",
"canUseHistory" : true,
"callbackUrl": "http://172.20.10.5:54315/Handler/SaveCallback.aspx",
"customization": {
"forcesave": true,
"autosave": true,
"trackChanges": true,
"buttons": {
"print": false,
"download": false
}
},
"user": {
"id": mGuid,
"name": mName
},
"history": {
"currentVersion": 2,
"data": [
{
"version": 1,
"key": onlyofficeguid,
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + onlyofficeguid + "&v=" + encodeURIComponent(fileNewName),
"created": "2025-06-03T09:00:00Z",
"user": { "id": mGuid, "name": mName }
},
{
"version": 2,
"key": "ver2-" + onlyofficeguid,
"url": "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + onlyofficeguid + "&v=" + encodeURIComponent("F-AD-2-10B_文件用印申請單_20250604145427.docx"),
"created": "2025-06-04T09:00:00Z",
"user": { "id": mGuid, "name": mName }
}
]
}
},
"permissions": {
"edit": true,
"review": true, // 開啟追蹤修訂按鈕
"comment": true,
"print": false,
"download": false
},
"token": authToken,
"height": "100%",
"width": "100%",
"type": "desktop",
"events": {
onDocumentReady: function () {
console.log("OnlyOffice Document Editor is ready. Enabling ForceSave button.");
$("#testForceSave").prop("disabled", false);
console.log("Inside onDocumentReady: docEditor is", docEditor);
if (docEditor) {
console.log("Inside onDocumentReady: typeof docEditor.forceSave is", typeof docEditor.forceSave);
}
}
}
};
docEditor = new DocsAPI.DocEditor("placeholder", editorConfig);
});
}
}
}
});
}
and below is the relevant code about JwtPayload in my GetFile.aspx
.
public static string GenerateJwt(string guid, string tmpGuid, string fileName, string fileNewname, string fileextension)
{
//將 JWT secret 包成 HmacSha256 的加密格式
var secret = ConfigurationManager.AppSettings["JwtSecret"];
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
//將payload用JSON格式包成跟前端一樣
var payload = new JwtPayload
{
{ "document", new Dictionary<string, object>
{
{ "fileType", "docx" },
{ "key", tmpGuid },
{ "title", fileName + fileextension },
{ "url", "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + tmpGuid + "&v=" + fileNewname + fileextension }
}
},
{ "documentType", "word" },
{ "editorConfig", new Dictionary<string, object>
{
{ "mode", "edit" },
{ "lang", "zh-TW" },
{ "callbackUrl", "http://172.20.10.5:54315/Handler/SaveCallback.aspx" },
{ "canUseHistory", true },
{ "customization", new Dictionary<string, object>
{
{ "forcesave", true },
{ "autosave", true },
{ "trackChanges", true },
{ "buttons", new Dictionary<string, object>
{
{ "print", false },
{ "download", false }
}
}
}
},
{ "user", new Dictionary<string, object>
{
{ "id", LogInfo.mGuid },
{ "name", LogInfo.name }
}
},
{ "history", new Dictionary<string, object>
{
{ "currentVersion", 1 },
{ "data", new List<Dictionary<string, object>>
{
new Dictionary<string, object>
{
{ "version", 1 },
{ "key", tmpGuid },
{ "url", "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + tmpGuid + "&v=" + fileNewname + fileextension },
{ "created", DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ssZ") },
{ "user", new Dictionary<string, object>
{
{ "id", LogInfo.mGuid },
{ "name", LogInfo.name }
}
}
},
new Dictionary<string, object>
{
{ "version", 2 },
{ "key", "ver2-" + tmpGuid },
{ "url", "http://172.20.10.5:54315/DOWNLOAD.aspx?category=Oil&type=suggestionimport&cpid=" + tmpGuid + "&v=F-AD-2-10B_文件用印申請單_20250604145427.docx" },
{ "created", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") },
{ "user", new Dictionary<string, object>
{
{ "id", LogInfo.mGuid },
{ "name", LogInfo.name }
}
}
}
}
}
}
}
}
},
{ "permissions", new Dictionary<string, object>
{
{ "edit", true },
{ "review", true },
{ "comment", true },
{ "print", false },
{ "download", false }
}
},
{ "height", "100%" },
{ "width", "100%" },
{ "type", "desktop" }
};
//組合 header + payload + signature
var token = new JwtSecurityToken(new JwtHeader(creds), payload);
//回傳 token 字串
return new JwtSecurityTokenHandler().WriteToken(token);
}
My questions are:
- Are there any additional parameters or configurations I need to include in the code to make the version history button appear in the editor?
- Even though we are using the 30-day Enterprise trial, some features still seem unavailable — for example, accepting or rejecting tracked changes doesn’t seem to trigger anything or save to our backend database.
Is this because the license shows"advanced_api": false
?
Additionally, I noticed that the print and download buttons cannot be hidden, even though I have explicitly set the following parameters to false
in the DocsAPI configuration
Thank you very much for your assistance.