private void ExportViaPDFSharp(bool bExportAllLayouts) { var zQuery = new QueryPanelDialog("Export to PDF (via PDFSharp)", 750, false); zQuery.SetIcon(Icon); const string ORIENTATION = "orientation"; const string OUTPUT_FILE = "output_file"; const string OPEN_ON_EXPORT = "open_on_export"; var nStartLayoutIdx = 0; var nEndLayoutIdx = ProjectManager.Instance.LoadedProject.Layout.Length; if (!bExportAllLayouts) { int nIdx = ProjectManager.Instance.GetLayoutIndex(LayoutManager.Instance.ActiveLayout); if (-1 == nIdx) { FormUtils.ShowErrorMessage("Unable to determine the current layout. Please select a layout in the tree view and try again."); return; } nStartLayoutIdx = nIdx; nEndLayoutIdx = nIdx + 1; } zQuery.AddPullDownBox("Page Orientation", new string[] { PageOrientation.Portrait.ToString(), PageOrientation.Landscape.ToString() }, m_nPdfExportLastOrientationIndex, ORIENTATION); var sExportFileName = string.IsNullOrWhiteSpace(m_sPdfExportLastFile) ? ProjectManager.Instance.ProjectPath + (bExportAllLayouts ? Path.GetFileNameWithoutExtension(ProjectManager.Instance.ProjectFilePath) + ".pdf" : LayoutManager.Instance.ActiveLayout.Name + ".pdf") : m_sPdfExportLastFile; zQuery.AddFileBrowseBox("Output File", sExportFileName, "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*", OUTPUT_FILE); zQuery.AddCheckBox("Open PDF on Export", m_bPdfExportLastOpen, OPEN_ON_EXPORT); if (DialogResult.OK != zQuery.ShowDialog(this)) { return; } m_sPdfExportLastFile = zQuery.GetString(OUTPUT_FILE); m_bPdfExportLastOpen = zQuery.GetBool(OPEN_ON_EXPORT); m_nPdfExportLastOrientationIndex = zQuery.GetIndex(ORIENTATION); if (!m_sPdfExportLastFile.EndsWith(".pdf", StringComparison.CurrentCultureIgnoreCase)) { m_sPdfExportLastFile += ".pdf"; } var zFileCardExporter = new PdfSharpExporter(nStartLayoutIdx, nEndLayoutIdx, m_sPdfExportLastFile, zQuery.GetString(ORIENTATION)); var zWait = CardMakerInstance.ProgressReporterFactory.CreateReporter( "Export", new string[] { ProgressName.LAYOUT, ProgressName.REFERENCE_DATA, ProgressName.CARD }, zFileCardExporter.ExportThread); #if true zFileCardExporter.ProgressReporter = zWait; zWait.StartProcessing(this); #else zFileCardExporter.ExportThread(); #endif if (zWait.ThreadSuccess && m_bPdfExportLastOpen && File.Exists(m_sPdfExportLastFile)) { Process.Start(m_sPdfExportLastFile); } }