diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index fadbca1ea..6d7751fdc 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -879,6 +879,15 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std: filterOptions += std::string(",Watermark=") + getWatermarkText() + std::string("WATERMARKEND"); } +#ifdef IOS + NSArray *pathComponents = [[NSURL URLWithString:[NSString stringWithUTF8String:getDocURL().c_str()]] pathComponents]; + NSString *baseName = [[pathComponents lastObject] stringByDeletingPathExtension]; + NSURL *documentDirectory = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0]; + NSURL *pdfURL = [documentDirectory URLByAppendingPathComponent:[baseName stringByAppendingString:@".pdf"]]; + getLOKitDocument()->saveAs([[pdfURL absoluteString] UTF8String], + format.empty() ? nullptr : format.c_str(), + filterOptions.empty() ? nullptr : filterOptions.c_str()); +#else // The file is removed upon downloading. const std::string tmpDir = FileUtil::createRandomDir(JAILED_DOCUMENT_ROOT); // Prevent user inputting anything funny here. @@ -898,6 +907,7 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std: sendTextFrame("downloadas: jail=" + _jailId + " dir=" + tmpDir + " name=" + name + " port=" + std::to_string(ClientPortNumber) + " id=" + id); +#endif return true; } diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index 41120cfc2..c71fee473 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -27,6 +27,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('Word 2003 Document (.doc)'), id: 'downloadas-doc', type: 'action'}, {name: _('Word Document (.docx)'), id: 'downloadas-docx', type: 'action'}, {name: _('Rich Text (.rtf)'), id: 'downloadas-rtf', type: 'action'}]}, + {name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'}, {name: _('Sign document'), id: 'signdocument', type: 'action'}, {type: 'separator'}, {name: _('Close document'), id: 'closedocument', type: 'action'} @@ -250,6 +251,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('ODF presentation (.odp)'), id: 'downloadas-odp', type: 'action'}, {name: _('PowerPoint 2003 Presentation (.ppt)'), id: 'downloadas-ppt', type: 'action'}, {name: _('PowerPoint Presentation (.pptx)'), id: 'downloadas-pptx', type: 'action'}]}, + {name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'}, {type: 'separator'}, {name: _('Close document'), id: 'closedocument', type: 'action'} ]}, @@ -338,6 +340,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('ODF spreadsheet (.ods)'), id: 'downloadas-ods', type: 'action'}, {name: _('Excel 2003 Spreadsheet (.xls)'), id: 'downloadas-xls', type: 'action'}, {name: _('Excel Spreadsheet (.xlsx)'), id: 'downloadas-xlsx', type: 'action'}]}, + {name: _('Save as PDF'), id: 'downloadas-pdf', mobileapp: true, type: 'action'}, {type: 'separator'}, {name: _('Close document'), id: 'closedocument', type: 'action'} ]}, @@ -996,6 +999,9 @@ L.Control.Menubar = L.Control.extend({ if (menu[i].mobileapp == false && window.ThisIsAMobileApp) { continue; } + if (menu[i].mobileapp == true && !window.ThisIsAMobileApp) { + continue; + } var ulItem = L.DomUtil.create('ul', '', liItem); var subitemList = this._createMenu(menu[i].menu); if (!subitemList.length) { diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js index 06563be19..f4ffa86f3 100644 --- a/loleaflet/src/control/Toolbar.js +++ b/loleaflet/src/control/Toolbar.js @@ -72,7 +72,8 @@ L.Map.include({ options = ''; } - this.showBusy(_('Downloading...'), false); + if (!window.ThisIsAMobileApp) + this.showBusy(_('Downloading...'), false); this._socket.sendMessage('downloadas ' + 'name=' + encodeURIComponent(name) + ' ' + 'id=' + id + ' ' +