diff --git a/BerichtGen/Bericht.cs b/BerichtGen/Bericht.cs
index 0d39824..8324310 100644
--- a/BerichtGen/Bericht.cs
+++ b/BerichtGen/Bericht.cs
@@ -1,11 +1,14 @@
using SanShared;
using Syncfusion.DocIO.DLS;
+using Syncfusion.DocToPDFConverter;
+using Syncfusion.Pdf;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -24,7 +27,7 @@ namespace BerichtGen
/// Inhalt vom Dokument
/// Ein doc datei soll erzeugt werden
/// Ein Pdf datei soll erzeugt werden
- public void Erzeuge(string source, string savepath, Hashtable daten,List bilderObjects,DataTable tableContents, bool erzeugeDOC = false , bool erzeugePDF = true)
+ public void Erzeuge(string source, string savepath,string filename, Hashtable daten,List bilderObjects,DataTable tableContents, bool erzeugeDOC = false , bool erzeugePDF = true)
{
if (bilderObjects != null)
{
@@ -65,19 +68,39 @@ namespace BerichtGen
}
- //wordDocument.MailMerge.Execute(fieldnames, fieldvalues);
+
wordDocument.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);
- //string[] fieldNames = new string[] { "UVImage" };
- //string[] fieldValues = new string[] { "test.png" };
+
if (tableContents != null)
wordDocument.MailMerge.ExecuteGroup(tableContents);
wordDocument.MailMerge.Execute(fieldnames, fieldvalues);
- wordDocument.Save("test.docx", Syncfusion.DocIO.FormatType.Docx);
- //wordDocument.Close();
- //wordDocument.MailMerge.ExecuteGroup()
+
+ if(erzeugeDOC)
+ wordDocument.Save(Path.Combine(savepath,string.Format("{0}.doc",filename)), Syncfusion.DocIO.FormatType.Doc);
+
+ if (erzeugePDF)
+ {
+ string speichername = Path.Combine(savepath, string.Format("{0}.pdf", filename));
+ DocToPDFConverter docToPDFConverter = new DocToPDFConverter();
+ PdfDocument pdf = docToPDFConverter.ConvertToPDF(wordDocument);
+ try
+ {
+ pdf.Save(speichername);
+
+ }
+ catch
+ {
+
+ }
+ finally
+ {
+ pdf.Dispose();
+ }
+ }
+
}
private readonly double _cmPixel = 0.393700787;
private readonly int _dpi = 120;
diff --git a/BerichtGen/BerichtGen.csproj b/BerichtGen/BerichtGen.csproj
index 601fece..536739a 100644
--- a/BerichtGen/BerichtGen.csproj
+++ b/BerichtGen/BerichtGen.csproj
@@ -76,12 +76,21 @@
FrmOptions.cs
+
+ Form
+
+
+ FrmPDFViewer.cs
+
FrmOptions.cs
+
+ FrmPDFViewer.cs
+
diff --git a/BerichtGen/FrmOptions.cs b/BerichtGen/FrmOptions.cs
index ee74234..bbca491 100644
--- a/BerichtGen/FrmOptions.cs
+++ b/BerichtGen/FrmOptions.cs
@@ -22,10 +22,11 @@ namespace BerichtGen
string vorlage;
string speicherpfad;
string source;
+ string filename;
List bilderObjects;
DataTable tableContent = null;
- public FrmOptions(string firma, string vorlage, string speicherpfad, Hashtable grunddaten, List bilderObjects, DataTable tableContent = null)
+ public FrmOptions(string firma, string vorlage, string speicherpfad,string filename, Hashtable grunddaten, List bilderObjects, DataTable tableContent = null)
{
InitializeComponent();
@@ -36,13 +37,13 @@ namespace BerichtGen
this.bilderObjects = bilderObjects;
this.tableContent = tableContent;
this.source = Path.Combine("documents", firma, vorlage);
-
+ this.filename = filename;
}
void Gen()
{
Bericht bericht = new Bericht();
- bericht.Erzeuge(source, speicherpfad, grundDaten, bilderObjects, tableContent);
+ bericht.Erzeuge(source, speicherpfad,filename, grundDaten, bilderObjects, tableContent,cb_doc.Checked,cb_pdf.Checked);
}
private void btn_start_Click(object sender, EventArgs e)
@@ -56,9 +57,11 @@ namespace BerichtGen
}
- if (rb_yes.Checked)
+ if (rb_yes.Checked && cb_pdf.Checked)
{
-
+ string pfad = Path.Combine(speicherpfad, string.Format("{0}.pdf", filename));
+ FrmPDFViewer frmPDFViewer = new FrmPDFViewer(pfad);
+ frmPDFViewer.ShowDialog();
}
this.Close();
diff --git a/BerichtGen/FrmPDFViewer.Designer.cs b/BerichtGen/FrmPDFViewer.Designer.cs
new file mode 100644
index 0000000..9190973
--- /dev/null
+++ b/BerichtGen/FrmPDFViewer.Designer.cs
@@ -0,0 +1,74 @@
+namespace BerichtGen
+{
+ partial class FrmPDFViewer
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ Syncfusion.Windows.PdfViewer.PdfViewerPrinterSettings pdfViewerPrinterSettings1 = new Syncfusion.Windows.PdfViewer.PdfViewerPrinterSettings();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmPDFViewer));
+ this.pdfViewerControl = new Syncfusion.Windows.Forms.PdfViewer.PdfViewerControl();
+ this.SuspendLayout();
+ //
+ // pdfViewerControl
+ //
+ this.pdfViewerControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pdfViewerControl.EnableNotificationBar = true;
+ this.pdfViewerControl.IsBookmarkEnabled = true;
+ this.pdfViewerControl.Location = new System.Drawing.Point(0, 0);
+ this.pdfViewerControl.Name = "pdfViewerControl";
+ this.pdfViewerControl.PageBorderThickness = 1;
+ pdfViewerPrinterSettings1.PrintLocation = ((System.Drawing.PointF)(resources.GetObject("pdfViewerPrinterSettings1.PrintLocation")));
+ this.pdfViewerControl.PrinterSettings = pdfViewerPrinterSettings1;
+ this.pdfViewerControl.ScrollDisplacementValue = 0;
+ this.pdfViewerControl.ShowHorizontalScrollBar = true;
+ this.pdfViewerControl.ShowToolBar = true;
+ this.pdfViewerControl.ShowVerticalScrollBar = true;
+ this.pdfViewerControl.Size = new System.Drawing.Size(638, 749);
+ this.pdfViewerControl.TabIndex = 0;
+ this.pdfViewerControl.Text = "pdfViewerControl1";
+ this.pdfViewerControl.ZoomMode = Syncfusion.Windows.Forms.PdfViewer.ZoomMode.FitPage;
+ //
+ // FrmPDFViewer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.ClientSize = new System.Drawing.Size(638, 749);
+ this.Controls.Add(this.pdfViewerControl);
+ this.Name = "FrmPDFViewer";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "FrmPDFViewer";
+ this.Load += new System.EventHandler(this.FrmPDFViewer_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Syncfusion.Windows.Forms.PdfViewer.PdfViewerControl pdfViewerControl;
+ }
+}
\ No newline at end of file
diff --git a/BerichtGen/FrmPDFViewer.cs b/BerichtGen/FrmPDFViewer.cs
new file mode 100644
index 0000000..68ab619
--- /dev/null
+++ b/BerichtGen/FrmPDFViewer.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace BerichtGen
+{
+ public partial class FrmPDFViewer : Form
+ {
+ string pfad;
+ public FrmPDFViewer(string pfad)
+ {
+ InitializeComponent();
+ this.pfad = pfad;
+ }
+
+ private void FrmPDFViewer_Load(object sender, EventArgs e)
+ {
+ pdfViewerControl.Load(pfad);
+ }
+ }
+}
diff --git a/BerichtGen/FrmPDFViewer.resx b/BerichtGen/FrmPDFViewer.resx
new file mode 100644
index 0000000..d9e357e
--- /dev/null
+++ b/BerichtGen/FrmPDFViewer.resx
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0
+ dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJh
+ d2luZy5Qb2ludEYCAAAAAXgBeQAACwsCAAAAAAAAAAAAAAAL
+
+
+
\ No newline at end of file
diff --git a/SanSystem/UCInliner.cs b/SanSystem/UCInliner.cs
index 5cd37bc..1fcb7d4 100644
--- a/SanSystem/UCInliner.cs
+++ b/SanSystem/UCInliner.cs
@@ -212,7 +212,7 @@ namespace SanSystem
Kommentar = "TestBild",
Path = @"C:\Users\Damian\Desktop\SanVerwaltung\SanSystem\bin\Debug\projekte\18-850\SW01-SW02\Schachtanbindung\4d0a1627-bd51-48d6-a27e-a4c6691b02d2.jpg"
});
- BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("", "", "", grunddaten,bilderO);
+ BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("", "", "","", grunddaten,bilderO);
options.ShowDialog();
}
@@ -314,7 +314,9 @@ namespace SanSystem
private void btn_create_protokol_Click(object sender, EventArgs e)
{
Hashtable hashtable = inliner.MakeProtokoll(destinationPath);
- BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "liner_einbau.docx", "./", hashtable, new List());
+ DirectoryInfo directory = Directory.GetParent(destinationPath);
+ string speicherpfad = directory.FullName;
+ BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "liner_einbau.docx", speicherpfad,inliner.Inspektionsobjekt.Objektbezeichnung, hashtable, new List());
options.ShowDialog();
}
}
diff --git a/SanSystem/frmObjekteList.cs b/SanSystem/frmObjekteList.cs
index 819969c..c1337d8 100644
--- a/SanSystem/frmObjekteList.cs
+++ b/SanSystem/frmObjekteList.cs
@@ -270,7 +270,7 @@ namespace SanSystem
dr["bemerkung"] = obj.Bemerkung;
linereintraege.Rows.Add(dr);
}
- BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "KalibrierungAuflistung.docx", "", grundDaten, null, linereintraege);
+ BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "KalibrierungAuflistung.docx", "","", grundDaten, null, linereintraege);
options.ShowDialog();
}