update 20250202
This commit is contained in:
@@ -13,6 +13,7 @@ using NLog;
|
||||
using System.Security.Policy;
|
||||
using OfficePrinter;
|
||||
using Syncfusion.XlsIO.Implementation.PivotAnalysis;
|
||||
using OnDocOffice;
|
||||
|
||||
namespace DOCGEN.Generator
|
||||
{
|
||||
@@ -94,6 +95,17 @@ namespace DOCGEN.Generator
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
if (useoffice == false) {
|
||||
Logging.Logging.Debug("Generate_Word", "Start", dokumentid);
|
||||
if (docdata.remove_signature)
|
||||
{
|
||||
Helper.clsFileHelper fh = new Helper.clsFileHelper();
|
||||
string filename = tempdir + dokumentid + ".tmp";
|
||||
fh.SaveBase64ToFile(dt.Rows[0][0].ToString(), filename);
|
||||
|
||||
word_signature ws = new word_signature();
|
||||
ws.remove_unterschriften_synfusion(filename);
|
||||
dt.Rows[0][0] = fh.Base64FromFile(filename);
|
||||
ws = null;
|
||||
}
|
||||
dok.dokument = sfword.Generate_Word(dt.Rows[0][0].ToString(), docdata);
|
||||
Logging.Logging.Debug("Generate_Word", "Ende", dokumentid);
|
||||
|
||||
|
||||
@@ -194,6 +194,38 @@ namespace DOCGEN.Klassen
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void insert_signature(string bookmark, string unterschrift, ref WordDocument document)
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
Syncfusion.DocIO.DLS.Bookmark bm = document.Bookmarks[bookmark];
|
||||
|
||||
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(unterschrift));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
|
||||
Shape signature = bm.BookmarkStart.OwnerParagraph.AppendShape(Syncfusion.DocIO.DLS.AutoShapeType.Rectangle,135,55);
|
||||
//IWParagraph p = bm.BookmarkStart.OwnerParagraph;
|
||||
//IWPicture u = p.AppendPicture(img);
|
||||
IWParagraph sigparagraph = signature.TextBody.AddParagraph();
|
||||
signature.WrapFormat.TextWrappingStyle = TextWrappingStyle.Behind;
|
||||
signature.LineFormat.DashStyle = LineDashing.Solid;
|
||||
signature.LineFormat.Color= Color.White;
|
||||
|
||||
signature.WrapFormat.AllowOverlap = true;
|
||||
signature.VerticalPosition = signature.VerticalPosition - 50;
|
||||
|
||||
//signature.HorizontalPosition = signature.HorizontalPosition + 200;
|
||||
|
||||
IWPicture p = sigparagraph.AppendPicture(img);
|
||||
p.Width = 120;
|
||||
p.Height = 50;
|
||||
signature.Name = "Unterschrift_" + bookmark;
|
||||
|
||||
|
||||
// signature.OwnerParagraph.AppendPicture(img);
|
||||
mssign = null;
|
||||
}
|
||||
public string Generate_Word(string base64, clsDocData docdata, string img_UL = "", string img_UR = "", string img_faktura = "", bool serienbrief=false)
|
||||
{
|
||||
string formattype = "";
|
||||
@@ -238,6 +270,9 @@ namespace DOCGEN.Klassen
|
||||
var formattype_original = document.ActualFormatType;
|
||||
string ppimg = "";
|
||||
string ppimg64 = "";
|
||||
|
||||
|
||||
|
||||
if (docdata.Barcode == true)
|
||||
{
|
||||
Insert_Barcode(document, docdata);
|
||||
@@ -280,10 +315,17 @@ namespace DOCGEN.Klassen
|
||||
//{
|
||||
// insert_ppfaktura(document, img_faktura);
|
||||
//}
|
||||
if (docdata.Form_ohne_Unterschrift == "True" || docdata.As_Faksimile == "True")
|
||||
{
|
||||
//DB db = new DB();
|
||||
}
|
||||
|
||||
//List<Entity> shapes = document.FindAllItemsByProperty(EntityType.Shape, null, null);
|
||||
//for (int i = 0; i < shapes.Count; i++)
|
||||
//{
|
||||
// Shape sh = shapes[i] as Shape;
|
||||
// if (sh.Name.Contains("Unterschrift_")){
|
||||
// int i1 = sh.OwnerParagraph.ChildEntities.Count;
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
@@ -320,22 +362,9 @@ namespace DOCGEN.Klassen
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
// if ((dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99" || dv.TMBeginn.ToString() == "TGEDKVornameNameRechtsB99") && docdata.As_Faksimile == "True")
|
||||
if ((dv.TMBeginn.ToString().Contains("VornameNameLinks") || dv.TMBeginn.ToString().Contains("VornameNameRechts")) && docdata.As_Faksimile == "True" && serienbrief==true)
|
||||
if ((dv.TMBeginn.ToString().Contains("VornameNameLinks") || dv.TMBeginn.ToString().Contains("VornameNameRechts")) && docdata.As_Faksimile == "True" && (docdata.sign == true || serienbrief==true))
|
||||
{
|
||||
string funktionlinks = "";
|
||||
string funktionrechts = "";
|
||||
foreach (clsDocValue dv2 in docdata.DocValues)
|
||||
{
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { funktionlinks = dv2.Value.ToString(); }
|
||||
//if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { funktionrechts = dv2.Value.ToString(); }
|
||||
if (dv2.TMBeginn.ToString().Contains("FunktionLinks")) { funktionlinks = dv2.Value.ToString(); }
|
||||
if (dv2.TMBeginn.ToString().Contains("FunktionRecht")) { funktionrechts = dv2.Value.ToString(); }
|
||||
}
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
IWParagraph paragraph = new WParagraph(document);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
|
||||
// if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
{
|
||||
string unterschrift = "";
|
||||
@@ -344,63 +373,113 @@ namespace DOCGEN.Klassen
|
||||
{
|
||||
unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Links));
|
||||
}
|
||||
if (unterschrift != "")
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(),true);
|
||||
if (docdata.Unterschrift_Links != "-1")
|
||||
{
|
||||
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(unterschrift));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
paragraph.AppendPicture(img);
|
||||
mssign.Dispose();
|
||||
img.Dispose();
|
||||
insert_signature(dv.TMBeginn.ToLower(), unterschrift, ref document);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (dv.TMBeginn.ToString().Contains("VornameNameRechts"))
|
||||
{
|
||||
string unterschrift = "";
|
||||
|
||||
if (img_UR != "") { unterschrift = img_UR; }
|
||||
if (img_UL != "") { unterschrift = img_UL.ToString(); }
|
||||
else
|
||||
{
|
||||
unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Rechts));
|
||||
}
|
||||
if (unterschrift != "")
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(),true);
|
||||
if (docdata.Unterschrift_Rechts != "-1")
|
||||
{
|
||||
MemoryStream mssign = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(unterschrift));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
mssign.Dispose();
|
||||
paragraph.AppendPicture(img);
|
||||
img.Dispose();
|
||||
insert_signature(dv.TMBeginn.ToLower(), unterschrift, ref document);
|
||||
}
|
||||
}
|
||||
// System.Drawing.Image image = System.Drawing.Image.FromFile(@"x:\docdemo\unterschriften\kube1.png");
|
||||
//paragraph.AppendPicture(image);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(dv.Value.ToString());
|
||||
//if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
{
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(funktionlinks);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
paragraph.AppendText(funktionrechts);
|
||||
|
||||
}
|
||||
//paragraph.rep
|
||||
bookmarkNavigator.InsertParagraph(paragraph);
|
||||
|
||||
|
||||
//string funktionlinks = "";
|
||||
//string funktionrechts = "";
|
||||
//foreach (clsDocValue dv2 in docdata.DocValues)
|
||||
//{
|
||||
// //if (dv2.TMBeginn.ToString() == "TGEDKFunktionLinksB99") { funktionlinks = dv2.Value.ToString(); }
|
||||
// //if (dv2.TMBeginn.ToString() == "TGEDKFunktionRechtsB99") { funktionrechts = dv2.Value.ToString(); }
|
||||
// if (dv2.TMBeginn.ToString().Contains("FunktionLinks")) { funktionlinks = dv2.Value.ToString(); }
|
||||
// if (dv2.TMBeginn.ToString().Contains("FunktionRecht")) { funktionrechts = dv2.Value.ToString(); }
|
||||
//}
|
||||
//bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
//IWParagraph paragraph = new WParagraph(document);
|
||||
//paragraph.AppendBreak(BreakType.LineBreak);
|
||||
|
||||
//// if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
//if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
//{
|
||||
// string unterschrift = "";
|
||||
// if (img_UL != "") { unterschrift = img_UL.ToString(); }
|
||||
// else
|
||||
// {
|
||||
// unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Links));
|
||||
// }
|
||||
// if (unterschrift != "")
|
||||
// {
|
||||
|
||||
// MemoryStream mssign = new MemoryStream(Convert.FromBase64String(unterschrift));
|
||||
// System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
// paragraph.AppendPicture(img);
|
||||
// mssign.Dispose();
|
||||
// img.Dispose();
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// string unterschrift = "";
|
||||
|
||||
// if (img_UR != "") { unterschrift = img_UR; }
|
||||
// else
|
||||
// {
|
||||
// unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Rechts));
|
||||
// }
|
||||
// if (unterschrift != "")
|
||||
// {
|
||||
// MemoryStream mssign = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(unterschrift));
|
||||
// System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
// mssign.Dispose();
|
||||
// paragraph.AppendPicture(img);
|
||||
// img.Dispose();
|
||||
// }
|
||||
//}
|
||||
//// System.Drawing.Image image = System.Drawing.Image.FromFile(@"x:\docdemo\unterschriften\kube1.png");
|
||||
////paragraph.AppendPicture(image);
|
||||
//paragraph.AppendBreak(BreakType.LineBreak);
|
||||
//paragraph.AppendText(dv.Value.ToString());
|
||||
////if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
//if (dv.TMBeginn.ToString().Contains("VornameNameLinks"))
|
||||
//{
|
||||
// paragraph.AppendBreak(BreakType.LineBreak);
|
||||
// paragraph.AppendText(funktionlinks);
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// paragraph.AppendBreak(BreakType.LineBreak);
|
||||
// paragraph.AppendText(funktionrechts);
|
||||
|
||||
//}
|
||||
////paragraph.rep
|
||||
//bookmarkNavigator.InsertParagraph(paragraph);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (docdata.As_Faksimile=="True" && (dv.TMBeginn.ToString() == "TGEDKFunktionLinksB99" || dv.TMBeginn.ToString() == "TGEDKFunktionRechtsB99"))
|
||||
if (docdata.As_Faksimile == "True" && (dv.TMBeginn.ToString().Contains("FunktionLinks") || dv.TMBeginn.ToString().Contains("FunktionRechts")) && serienbrief == true)
|
||||
{
|
||||
//if (docdata.As_Faksimile == "True" && (dv.TMBeginn.ToString().Contains("FunktionLinks") || dv.TMBeginn.ToString().Contains("FunktionRechts")) && serienbrief == true)
|
||||
//{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//if (dv.TMBeginn.ToString() == "TGEDKAdresseZustellungB99")
|
||||
if (dv.TMBeginn.ToString() == "TGEDKZustellungB99")
|
||||
{
|
||||
@@ -445,7 +524,7 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -491,38 +570,39 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
|
||||
}
|
||||
if (docdata.As_Faksimile == "True" && serienbrief==true)
|
||||
{
|
||||
//gaga
|
||||
//if (docdata.As_Faksimile == "True" && serienbrief==true)
|
||||
//{
|
||||
|
||||
TextSelection[] textSelections = document.FindAll("Thurgauer Kantonalbank", false, true);
|
||||
foreach (TextSelection selection in textSelections)
|
||||
{
|
||||
WTextRange textRange = selection.GetAsOneRange();
|
||||
WTextBody ownerTextBody = textRange.OwnerParagraph.OwnerTextBody;
|
||||
//Get the index of the paragraph with specified text
|
||||
int ownerParaIndex = ownerTextBody.ChildEntities.IndexOf(textRange.OwnerParagraph);
|
||||
//Check whether the previous and next paragraphs are empty and remove them
|
||||
if (ownerParaIndex > 0 && ownerTextBody.ChildEntities[ownerParaIndex - 1] is WParagraph &&
|
||||
(ownerTextBody.ChildEntities[ownerParaIndex - 1] as WParagraph).Items.Count == 0)
|
||||
{
|
||||
ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex - 1);
|
||||
}
|
||||
if (ownerParaIndex + 1 < ownerTextBody.ChildEntities.Count &&
|
||||
ownerTextBody.ChildEntities[ownerParaIndex + 1] is WParagraph &&
|
||||
(ownerTextBody.ChildEntities[ownerParaIndex + 1] as WParagraph).Items.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex + 1);
|
||||
// TextSelection[] textSelections = document.FindAll("Thurgauer Kantonalbank", false, true);
|
||||
// foreach (TextSelection selection in textSelections)
|
||||
// {
|
||||
// WTextRange textRange = selection.GetAsOneRange();
|
||||
// WTextBody ownerTextBody = textRange.OwnerParagraph.OwnerTextBody;
|
||||
// //Get the index of the paragraph with specified text
|
||||
// int ownerParaIndex = ownerTextBody.ChildEntities.IndexOf(textRange.OwnerParagraph);
|
||||
// //Check whether the previous and next paragraphs are empty and remove them
|
||||
// if (ownerParaIndex > 0 && ownerTextBody.ChildEntities[ownerParaIndex - 1] is WParagraph &&
|
||||
// (ownerTextBody.ChildEntities[ownerParaIndex - 1] as WParagraph).Items.Count == 0)
|
||||
// {
|
||||
// ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex - 1);
|
||||
// }
|
||||
// if (ownerParaIndex + 1 < ownerTextBody.ChildEntities.Count &&
|
||||
// ownerTextBody.ChildEntities[ownerParaIndex + 1] is WParagraph &&
|
||||
// (ownerTextBody.ChildEntities[ownerParaIndex + 1] as WParagraph).Items.Count == 0)
|
||||
// {
|
||||
// for (int i = 0; i < 4; i++)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ownerTextBody.ChildEntities.RemoveAt(ownerParaIndex + 1);
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// catch { }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach (clsDocMacro dm in docdata.DocMacros)
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,6 +20,7 @@ using System.Configuration;
|
||||
using Syncfusion.DocIO;
|
||||
using Syncfusion.Pdf;
|
||||
using System.IO;
|
||||
using Syncfusion.Compression.Zip;
|
||||
|
||||
namespace DOCGEN
|
||||
{
|
||||
@@ -119,6 +120,31 @@ namespace DOCGEN
|
||||
return dok.dokument;
|
||||
}
|
||||
|
||||
public bool signdoc(string dokumentid, string tempdir)
|
||||
{
|
||||
DB db1 = new DB(connectionstring);
|
||||
try
|
||||
{
|
||||
|
||||
db1.Get_Tabledata("Select * from dokument where dokumentid = '" + dokumentid + "'", false, true);
|
||||
string unterschriftlinks = db1.dsdaten.Tables[0].Rows[0]["unterschriftlinks"].ToString();
|
||||
string unterschriftrechts = db1.dsdaten.Tables[0].Rows[0]["unterschriftrechts"].ToString();
|
||||
|
||||
OnDocOffice.clsWordEdit we = new OnDocOffice.clsWordEdit(connectionstring, "", "", resturi, apikey);
|
||||
if (we.insert_signature(dokumentid, unterschriftlinks, unterschriftrechts, tempdir))
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
finally { db1 = null; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//public void createpdf(string filename)
|
||||
//{
|
||||
// WordDocument document = new WordDocument(filename, FormatType.Automatic);
|
||||
@@ -144,4 +170,6 @@ namespace DOCGEN
|
||||
// };
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user