Merge pull request #1572 from ONLYOFFICE/fix/pdf-download

Fix/pdf download
This commit is contained in:
Julia Radzhabova 2022-02-16 13:02:13 +03:00 committed by GitHub
commit 47c582de47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 25 deletions

View file

@ -314,7 +314,6 @@ define([
options.asc_setTextParams(textParams); options.asc_setTextParams(textParams);
if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) {
Common.UI.warning({ Common.UI.warning({
closable: false,
title: this.notcriticalErrorTitle, title: this.notcriticalErrorTitle,
msg: (format == Asc.c_oAscFileType.TXT) ? this.warnDownloadAs : this.warnDownloadAsRTF, msg: (format == Asc.c_oAscFileType.TXT) ? this.warnDownloadAs : this.warnDownloadAsRTF,
buttons: ['ok', 'cancel'], buttons: ['ok', 'cancel'],
@ -374,22 +373,17 @@ define([
} else if (format == Asc.c_oAscFileType.PDF || format == Asc.c_oAscFileType.PDFA) } else if (format == Asc.c_oAscFileType.PDF || format == Asc.c_oAscFileType.PDFA)
this._saveAsFormat(menu, format, ext); this._saveAsFormat(menu, format, ext);
else { else {
(new Common.Views.OptionsDialog({ Common.UI.warning({
width: 300, width: 600,
title: this.titleConvertOptions, title: this.notcriticalErrorTitle,
label: this.textGroup, msg: Common.Utils.String.format(this.warnDownloadAsPdf, fileType.toUpperCase()),
items: [ buttons: ['ok', 'cancel'],
{caption: this.textChar, value: Asc.c_oAscTextAssociation.BlockChar, checked: true}, callback: _.bind(function(btn){
{caption: this.textLine, value: Asc.c_oAscTextAssociation.BlockLine, checked: false}, if (btn == 'ok') {
{caption: this.textParagraph, value: Asc.c_oAscTextAssociation.PlainLine, checked: false} me._saveAsFormat(menu, format, ext, new AscCommon.asc_CTextParams(Asc.c_oAscTextAssociation.PlainLine));
],
handler: function (dlg, result) {
if (result=='ok') {
me._saveAsFormat(menu, format, ext, new AscCommon.asc_CTextParams(dlg.getSettings()));
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, this)
} });
})).show();
} }
} else } else
this._saveAsFormat(menu, format, ext); this._saveAsFormat(menu, format, ext);
@ -930,11 +924,7 @@ define([
warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?', warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?',
txtUntitled: 'Untitled', txtUntitled: 'Untitled',
txtCompatible: 'The document will be saved to the new format. It will allow to use all the editor features, but might affect the document layout.<br>Use the \'Compatibility\' option of the advanced settings if you want to make the files compatible with older MS Word versions.', txtCompatible: 'The document will be saved to the new format. It will allow to use all the editor features, but might affect the document layout.<br>Use the \'Compatibility\' option of the advanced settings if you want to make the files compatible with older MS Word versions.',
titleConvertOptions: 'Grouping options', warnDownloadAsPdf: 'Your {0} will be converted to an editable format. This may take a while. The resulting document will be optimized to allow you to edit the text, so it might not look exactly like the original {0}, especially if the original file contained lots of graphics.'
textGroup: 'Group by',
textChar: 'Char',
textLine: 'Line',
textParagraph: 'Paragraph'
}, DE.Controllers.LeftMenu || {})); }, DE.Controllers.LeftMenu || {}));
}); });

View file

@ -552,6 +552,7 @@ define([
this._state.isFromGatewayDownloadAs = true; this._state.isFromGatewayDownloadAs = true;
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null, var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_defaultFormat = null, _defaultFormat = null,
textParams,
_supported = [ _supported = [
Asc.c_oAscFileType.TXT, Asc.c_oAscFileType.TXT,
Asc.c_oAscFileType.RTF, Asc.c_oAscFileType.RTF,
@ -575,6 +576,7 @@ define([
else if (/^djvu$/.test(this.document.fileType)) { else if (/^djvu$/.test(this.document.fileType)) {
_supported = [Asc.c_oAscFileType.PDF]; _supported = [Asc.c_oAscFileType.PDF];
} }
textParams = new AscCommon.asc_CTextParams(Asc.c_oAscTextAssociation.PlainLine);
} else { } else {
_supported = _supported.concat([Asc.c_oAscFileType.PDF, Asc.c_oAscFileType.PDFA]); _supported = _supported.concat([Asc.c_oAscFileType.PDF, Asc.c_oAscFileType.PDFA]);
_defaultFormat = Asc.c_oAscFileType.DOCX; _defaultFormat = Asc.c_oAscFileType.DOCX;
@ -584,7 +586,13 @@ define([
} }
if ( !_format || _supported.indexOf(_format) < 0 ) if ( !_format || _supported.indexOf(_format) < 0 )
_format = _defaultFormat; _format = _defaultFormat;
_format ? this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(_format, true)) : this.api.asc_DownloadOrigin(true); if (_format) {
var options = new Asc.asc_CDownloadOptions(_format, true);
textParams && options.asc_setTextParams(textParams);
this.api.asc_DownloadAs(options);
} else {
this.api.asc_DownloadOrigin(true);
}
}, },
onProcessMouse: function(data) { onProcessMouse: function(data) {

View file

@ -1289,7 +1289,6 @@ define([
!Common.Utils.ModalWindow.isVisible() && !Common.Utils.ModalWindow.isVisible() &&
Common.UI.warning({ Common.UI.warning({
width: 500, width: 500,
closable: false,
msg: this.confirmAddFontName, msg: this.confirmAddFontName,
buttons: ['yes', 'no'], buttons: ['yes', 'no'],
primary: 'yes', primary: 'yes',

View file

@ -513,6 +513,7 @@
"DE.Controllers.LeftMenu.txtUntitled": "Untitled", "DE.Controllers.LeftMenu.txtUntitled": "Untitled",
"DE.Controllers.LeftMenu.warnDownloadAs": "If you continue saving in this format all features except the text will be lost.<br>Are you sure you want to continue?", "DE.Controllers.LeftMenu.warnDownloadAs": "If you continue saving in this format all features except the text will be lost.<br>Are you sure you want to continue?",
"DE.Controllers.LeftMenu.warnDownloadAsRTF": "If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?", "DE.Controllers.LeftMenu.warnDownloadAsRTF": "If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?",
"DE.Controllers.LeftMenu.warnDownloadAsPdf": "Your {0} will be converted to an editable format. This may take a while. The resulting document will be optimized to allow you to edit the text, so it might not look exactly like the original {0}, especially if the original file contained lots of graphics.",
"DE.Controllers.Main.applyChangesTextText": "Loading the changes...", "DE.Controllers.Main.applyChangesTextText": "Loading the changes...",
"DE.Controllers.Main.applyChangesTitleText": "Loading the Changes", "DE.Controllers.Main.applyChangesTitleText": "Loading the Changes",
"DE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.", "DE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.",

View file

@ -1272,7 +1272,6 @@ define([
!Common.Utils.ModalWindow.isVisible() && !Common.Utils.ModalWindow.isVisible() &&
Common.UI.warning({ Common.UI.warning({
width: 500, width: 500,
closable: false,
msg: this.confirmAddFontName, msg: this.confirmAddFontName,
buttons: ['yes', 'no'], buttons: ['yes', 'no'],
primary: 'yes', primary: 'yes',

View file

@ -1573,7 +1573,6 @@ define([
!Common.Utils.ModalWindow.isVisible() && !Common.Utils.ModalWindow.isVisible() &&
Common.UI.warning({ Common.UI.warning({
width: 500, width: 500,
closable: false,
msg: this.confirmAddFontName, msg: this.confirmAddFontName,
buttons: ['yes', 'no'], buttons: ['yes', 'no'],
primary: 'yes', primary: 'yes',