NAPS2.WinForms.DialogHelper.PromptToSavePdf C# (CSharp) Method

PromptToSavePdf() public method

public PromptToSavePdf ( string defaultPath, string &savePath ) : bool
defaultPath string
savePath string
return bool
        public bool PromptToSavePdf(string defaultPath, out string savePath)
        {
            var sd = new SaveFileDialog
            {
                OverwritePrompt = false,
                AddExtension = true,
                Filter = MiscResources.FileTypePdf + "|*.pdf",
                FileName = Path.GetFileName(defaultPath),
                InitialDirectory = GetDir(defaultPath)
            };
            if (sd.ShowDialog() == DialogResult.OK)
            {
                savePath = sd.FileName;
                return true;
            }
            savePath = null;
            return false;
        }

Usage Example

示例#1
0
        public async Task <bool> SavePDF(List <ScannedImage> images, ISaveNotify notify)
        {
            if (images.Any())
            {
                string savePath;

                var pdfSettings = pdfSettingsContainer.PdfSettings;
                if (pdfSettings.SkipSavePrompt && Path.IsPathRooted(pdfSettings.DefaultFileName))
                {
                    savePath = pdfSettings.DefaultFileName;
                }
                else
                {
                    if (!dialogHelper.PromptToSavePdf(pdfSettings.DefaultFileName, out savePath))
                    {
                        return(false);
                    }
                }

                var subSavePath = fileNamePlaceholders.SubstitutePlaceholders(savePath, DateTime.Now);
                var changeToken = changeTracker.State;
                if (await ExportPDF(subSavePath, images, false, null))
                {
                    changeTracker.Saved(changeToken);
                    notify?.PdfSaved(subSavePath);
                    return(true);
                }
            }
            return(false);
        }
All Usage Examples Of NAPS2.WinForms.DialogHelper::PromptToSavePdf