using System.Diagnostics; using System.IO; public class ExportProjectAsPDF { [DeclareAction("ExportProjectAsPDF")] public void ExportProjectAsPDFVoid() { //Projekt; Projektname ermitteln und Endung abschneiden. string sProjectName = PathMap.SubstitutePath("$(PROJECTNAME)"); string Projectpath = PathMap.SubstitutePath("$(PROJECTPATH)"); Projectpath = Projectpath.Substring(0, Projectpath.LastIndexOf("\\")) + @"\"; FolderBrowserDialog dlgBrowserOpen = new FolderBrowserDialog(); if (dlgBrowserOpen.ShowDialog() == DialogResult.OK) { string strMeldung = "Wollen Sie das Projekt im Verzeichnis " + Environment.NewLine + Environment.NewLine + dlgBrowserOpen.SelectedPath + Environment.NewLine + Environment.NewLine + "sichern?"; DialogResult result = MessageBox.Show(strMeldung, "Hier sichern?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { ActionCallingContext exportContext = new ActionCallingContext(); exportContext.AddParameter("TYPE", "PDFPROJECT"); exportContext.AddParameter("EXPORTFILE", Projectpath + sProjectName); exportContext.AddParameter("USESIMPLELINK", "1"); //1 = einfache Sprungfunktion exportContext.AddParameter("FASTWEBVIEW", "1"); //1 = schnelle Web-Anzeige exportContext.AddParameter("READONLYEXPORT", "1"); //1 = PDF wird schreibgeschützt exportContext.AddParameter("BLACKWHITE", "0"); //0 = PDF wird farbig // PDF: Prüfung, ob die Datei schon vorhanden ist. if (File.Exists(Projectpath + sProjectName + ".pdf")) { DialogResult oDialogResult = MessageBox.Show("Die PDF-Datei existiert bereits. Soll diese Datei überschrieben werden?", "Gesamtes Projekt als PDF exportieren", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (oDialogResult == DialogResult.Yes) { // PDF: Action Progress ProgressPDF = new Progress("ProgressPDF"); ProgressPDF.BeginPart(100, ""); ProgressPDF.SetAllowCancel(true); new CommandLineInterpreter().Execute("export", exportContext); ProgressPDF.EndPart(true); // PDF: Öffnen Process pPDF = new Process(); System.Diagnostics.Process.Start(Projectpath + sProjectName + ".pdf"); } return; } else { // PDF: Action Progress ProgressPDF = new Progress("ProgressPDF"); ProgressPDF.BeginPart(100, ""); ProgressPDF.SetAllowCancel(true); new CommandLineInterpreter().Execute("export", exportContext); ProgressPDF.EndPart(true); // PDF: Öffnen Process pPDF = new Process(); System.Diagnostics.Process.Start(Projectpath + sProjectName + ".pdf"); } } } } }