Update 20250222
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,6 +28,7 @@ using System.Runtime.InteropServices.ComTypes;
|
||||
using Syncfusion.CompoundFile.DocIO;
|
||||
using Helper;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using System.Data.Common;
|
||||
|
||||
|
||||
namespace OnDocOffice
|
||||
@@ -668,7 +669,7 @@ namespace OnDocOffice
|
||||
{ }
|
||||
if (docdata.remove_signature)
|
||||
{
|
||||
word_signature ws = new word_signature();
|
||||
word_signature ws = new word_signature(this.connectstring);
|
||||
ws.remove_unterschriften(ref word, dokumentid);
|
||||
ws = null;
|
||||
}
|
||||
@@ -699,8 +700,8 @@ namespace OnDocOffice
|
||||
path_unterschriftrechts = tempdir + dokumentid + "UR.png";
|
||||
clsFileHelper.SaveBase64ToFile(unterschriftrechts,path_unterschriftrechts);
|
||||
}
|
||||
word_signature word_Signature = new word_signature();
|
||||
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid);
|
||||
word_signature word_Signature = new word_signature(connectionstring);
|
||||
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid, docdata.DokumenttypNr);
|
||||
if (System.IO.File.Exists(path_unterschriftlinks)){ System.IO.File.Delete(tempdir + dokumentid + "UL.png"); };
|
||||
if (System.IO.File.Exists(path_unterschriftrechts)){ System.IO.File.Delete(tempdir + dokumentid + "UR.png"); }
|
||||
|
||||
@@ -1537,7 +1538,7 @@ namespace OnDocOffice
|
||||
return;
|
||||
|
||||
}
|
||||
public bool insert_signature(string dokumentid, string unterschriftlinks, string unterschriftrechts, string tempdir)
|
||||
public bool insert_signature(string dokumentid, string unterschriftlinks, string unterschriftrechts, string tempdir, string dokumenttypnr )
|
||||
{
|
||||
DB db = new DB(this.connectstring);
|
||||
System.Data.DataTable dt = new System.Data.DataTable();
|
||||
@@ -1582,8 +1583,8 @@ namespace OnDocOffice
|
||||
path_unterschriftrechts = tempdir + dokumentid + "UR.png";
|
||||
clsFileHelper.SaveBase64ToFile(unterschriftrechts, path_unterschriftrechts);
|
||||
}
|
||||
word_signature word_Signature = new word_signature();
|
||||
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid);
|
||||
word_signature word_Signature = new word_signature(this.connectstring);
|
||||
word_Signature.sign_doc(ref word, path_unterschriftlinks, path_unterschriftrechts, dokumentid,dokumenttypnr);
|
||||
if (System.IO.File.Exists(path_unterschriftlinks)) { System.IO.File.Delete(tempdir + dokumentid + "UL.png"); };
|
||||
if (System.IO.File.Exists(path_unterschriftrechts)) { System.IO.File.Delete(tempdir + dokumentid + "UR.png"); }
|
||||
|
||||
@@ -1606,13 +1607,24 @@ namespace OnDocOffice
|
||||
|
||||
public class word_signature
|
||||
{
|
||||
|
||||
private string ConnectionString = "";
|
||||
|
||||
public word_signature(string connectionstring)
|
||||
{
|
||||
ConnectionString = connectionstring.Trim();
|
||||
}
|
||||
bool is_protected = false;
|
||||
Microsoft.Office.Interop.Word.Document docWord;
|
||||
public bool sign_doc(ref Microsoft.Office.Interop.Word.Application word, string imagepath_ul, string imagepath_ur, string dokumentid)
|
||||
public bool sign_doc(ref Microsoft.Office.Interop.Word.Application word, string imagepath_ul, string imagepath_ur, string dokumentid, string dokumenttypnr)
|
||||
{
|
||||
Logging.Logging.Debug("Sign_Doc", "OnDoc", dokumentid);
|
||||
docWord = word.ActiveDocument;
|
||||
|
||||
|
||||
DB db = new DB(this.ConnectionString);
|
||||
db.Get_Tabledata("Select * from OnDocSignaturePosition where dokumenttypnr=1089");
|
||||
System.Data.DataTable position = db.dsdaten.Tables[0];
|
||||
db = null;
|
||||
Thread.Sleep(1000);
|
||||
if (word.ActiveDocument.ProtectionType != Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection)
|
||||
{
|
||||
@@ -1620,18 +1632,41 @@ namespace OnDocOffice
|
||||
is_protected = true;
|
||||
}
|
||||
|
||||
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int l = 0;
|
||||
int t = 0;
|
||||
try
|
||||
{
|
||||
foreach (Microsoft.Office.Interop.Word.Bookmark bm in docWord.Bookmarks)
|
||||
{
|
||||
if (bm.Name.Contains("VornameNameLinks") || bm.Name.Contains("UnterschriftLinks"))
|
||||
{
|
||||
insert_unterschrift(bm.Name, imagepath_ul);
|
||||
foreach (System.Data.DataRow dr in position.Rows)
|
||||
{
|
||||
if (bm.Name.ToUpper() == dr["bookmark"].ToString().ToUpper())
|
||||
{
|
||||
l = Convert.ToInt32("posleft");
|
||||
t = Convert.ToInt32("postop");
|
||||
w = Convert.ToInt32("width");
|
||||
h = Convert.ToInt32("height");
|
||||
}
|
||||
}
|
||||
insert_unterschrift(bm.Name, imagepath_ul,l,t,w,h);
|
||||
}
|
||||
if (bm.Name.Contains("VornameNameRechts") || bm.Name.Contains("UnterschriftRechts"))
|
||||
{
|
||||
insert_unterschrift(bm.Name, imagepath_ur);
|
||||
foreach (System.Data.DataRow dr in position.Rows)
|
||||
{
|
||||
if (bm.Name.ToUpper() == dr["bookmark"].ToString().ToUpper())
|
||||
{
|
||||
l = Convert.ToInt32("posleft");
|
||||
t = Convert.ToInt32("postop");
|
||||
w = Convert.ToInt32("width");
|
||||
h = Convert.ToInt32("height");
|
||||
}
|
||||
}
|
||||
insert_unterschrift(bm.Name, imagepath_ur,l,t,w,h);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1656,7 +1691,7 @@ namespace OnDocOffice
|
||||
}
|
||||
}
|
||||
|
||||
public void insert_unterschrift(string bookmark, string imagepath)
|
||||
public void insert_unterschrift(string bookmark, string imagepath, int l, int t, int w, int h)
|
||||
{
|
||||
if (imagepath == "") return;
|
||||
|
||||
@@ -1668,11 +1703,13 @@ namespace OnDocOffice
|
||||
|
||||
///
|
||||
Microsoft.Office.Interop.Word.Bookmark bm = docWord.Bookmarks[bookmark];
|
||||
bm.Select();
|
||||
bm.Range.GoTo();
|
||||
bm.Select();
|
||||
|
||||
Microsoft.Office.Interop.Word.Shape myShape1 = docWord.Shapes.AddPicture(imagepath, false, true, 0, 0, 120, 50, missing);
|
||||
myShape1.Top = myShape1.Top - myShape1.Height;
|
||||
//myShape1.Top = myShape1.Top - myShape1.Height;
|
||||
myShape1.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;
|
||||
|
||||
return;
|
||||
///
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user