[bug] Add "oformAsPdf" conversion flag for PDF editor

This commit is contained in:
Sergey Konovalov
2025-06-23 18:37:59 +03:00
parent 5b75a161dc
commit dcc196f17a
3 changed files with 18 additions and 2 deletions

View File

@ -108,6 +108,7 @@ function InputCommand(data, copyExplicit) {
this['convertToOrigin'] = data['convertToOrigin'];
this['isSaveAs'] = data['isSaveAs'];
this['saveAsPath'] = data['saveAsPath'];
this['oformAsPdf'] = data['oformAsPdf'];
if (copyExplicit) {
this['withAuthorization'] = data['withAuthorization'];
this['externalChangeInfo'] = data['externalChangeInfo'];
@ -170,6 +171,7 @@ function InputCommand(data, copyExplicit) {
this['originformat'] = undefined;
this['isSaveAs'] = undefined;
this['saveAsPath'] = undefined;
this['oformAsPdf'] = undefined;
}
}
InputCommand.prototype = {
@ -503,6 +505,12 @@ InputCommand.prototype = {
},
setSaveAsPath: function(data) {
this['saveAsPath'] = data;
},
getOformAsPdf: function() {
return this['oformAsPdf'];
},
setOformAsPdf: function(data) {
this['oformAsPdf'] = data;
}
};

View File

@ -279,6 +279,7 @@ function convertRequest(req, res, isJson) {
utils.fillResponse(req, res, new commonDefines.ConvertStatus(constants.CONVERT_PARAMS), isJson);
return;
}
let oformAsPdf;
if (params.pdf) {
if (true === params.pdf.pdfa && constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF === outputFormat) {
outputFormat = constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA;
@ -288,6 +289,8 @@ function convertRequest(req, res, isJson) {
if (params.pdf.form && (constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF === outputFormat ||
constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA === outputFormat)) {
outputFormat = constants.AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF;
} else if (false === params.pdf.form) {
oformAsPdf = true;
}
}
//todo use hash of params as id
@ -299,6 +302,7 @@ function convertRequest(req, res, isJson) {
cmd.setFormat(filetype);
cmd.setDocId(docId);
cmd.setOutputFormat(outputFormat);
cmd.setOformAsPdf(oformAsPdf);
let outputExt = formatChecker.getStringFromFormat(cmd.getOutputFormat());
cmd.setCodepage(commonDefines.c_oAscEncodingsMap[params.codePage] || commonDefines.c_oAscCodePageUtf8);

View File

@ -133,6 +133,7 @@ function TaskQueueDataConvert(ctx, task) {
this.savePassword = cmd.getSavePassword();
this.noBase64 = cmd.getNoBase64();
this.convertToOrigin = cmd.getConvertToOrigin();
this.oformAsPdf = cmd.getOformAsPdf();
this.timestamp = new Date();
}
TaskQueueDataConvert.prototype = {
@ -169,7 +170,7 @@ TaskQueueDataConvert.prototype = {
xml += this.serializeXmlProp('m_bIsNoBase64', this.noBase64);
xml += this.serializeXmlProp('m_sConvertToOrigin', this.convertToOrigin);
xml += this.serializeLimit(ctx);
xml += this.serializeOptions(ctx, false);
xml += this.serializeOptions(ctx, false, this.oformAsPdf);
xml += '</TaskQueueDataConvert>';
fs.writeFileSync(fsPath, xml, {encoding: 'utf8'});
},
@ -192,7 +193,7 @@ TaskQueueDataConvert.prototype = {
return xml;
});
},
serializeOptions: function (ctx, isInJwtToken) {
serializeOptions: function (ctx, isInJwtToken, oformAsPdf) {
const tenRequesFilteringAgent = ctx.getCfg('services.CoAuthoring.request-filtering-agent', cfgRequesFilteringAgent);
const tenExternalRequestDirectIfIn = ctx.getCfg('externalRequest.directIfIn', cfgExternalRequestDirectIfIn);
const tenExternalRequestAction = ctx.getCfg('externalRequest.action', cfgExternalRequestAction);
@ -231,6 +232,9 @@ TaskQueueDataConvert.prototype = {
if (proxyHeadersStr.length > 0) {
xml += this.serializeXmlProp('proxyHeader', proxyHeadersStr.join(';'));
}
if (undefined !== oformAsPdf) {
xml += this.serializeXmlProp('oformAsPdf', oformAsPdf);
}
xml += '</options>';
return xml;
},