update 20241128
This commit is contained in:
@@ -32,6 +32,8 @@ using Syncfusion.XlsIO;
|
||||
using System.Security.Permissions;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +80,35 @@ namespace DOCGEN.Klassen
|
||||
|
||||
}
|
||||
|
||||
private string get_image(int imageid, int width, int height)
|
||||
{
|
||||
string URL = resturi + "API/GetImageAsBase64?imageid=" + imageid.ToString() + "&ImageWidth=" + width.ToString() + "&ImageHeight=" + height.ToString();
|
||||
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
||||
webRequest.Method = WebRequestMethods.Http.Get;
|
||||
webRequest.Headers["Authorization"] = "Bearer " + apikey;
|
||||
try
|
||||
{
|
||||
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
string responseContent = reader.ReadToEnd();
|
||||
|
||||
return responseContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Client - GetImage", "");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private string get_unterschrift(string MaNr)
|
||||
{
|
||||
|
||||
@@ -115,7 +146,7 @@ namespace DOCGEN.Klassen
|
||||
// return (Image)new Bitmap(imgToResize, size);
|
||||
|
||||
//}
|
||||
public string Generate_Word(string base64, clsDocData docdata)
|
||||
public string Generate_Word(string base64, clsDocData docdata, string img_UL="", string img_UR="",string img_faktura="")
|
||||
{
|
||||
string formattype = "";
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(base64));
|
||||
@@ -137,7 +168,12 @@ namespace DOCGEN.Klassen
|
||||
if (compatibilityMode > CompatibilityMode.Word2010) { document.Settings.CompatibilityMode = CompatibilityMode.Word2010; }
|
||||
formattype = document.ActualFormatType.ToString();
|
||||
var formattype_original = document.ActualFormatType;
|
||||
|
||||
string ppimg = "";
|
||||
string ppimg64 = "";
|
||||
if (img_faktura != "")
|
||||
{
|
||||
insert_ppfaktura(document, img_faktura);
|
||||
}
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
{
|
||||
if (docdata.Form_ohne_Unterschrift == "True")
|
||||
@@ -167,15 +203,15 @@ namespace DOCGEN.Klassen
|
||||
bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString());
|
||||
IWParagraph paragraph = new WParagraph(document);
|
||||
paragraph.AppendBreak(BreakType.LineBreak);
|
||||
|
||||
|
||||
if (dv.TMBeginn.ToString() == "TGEDKVornameNameLinksB99")
|
||||
{
|
||||
string unterschrift = get_unterschrift(docdata.Unterschrift_Links);
|
||||
string unterschrift = "";
|
||||
if (img_UL != "") { unterschrift = img_UL.ToString(); } else {
|
||||
unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Links)); }
|
||||
if (unterschrift != "")
|
||||
{
|
||||
string ss = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(unterschrift);
|
||||
|
||||
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(ss));
|
||||
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(unterschrift));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
paragraph.AppendPicture(img);
|
||||
mssign.Dispose();
|
||||
@@ -184,11 +220,13 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
else
|
||||
{
|
||||
string unterschrift = get_unterschrift(docdata.Unterschrift_Rechts);
|
||||
string unterschrift = "";
|
||||
|
||||
if (img_UR != "") { unterschrift = img_UR; } else {
|
||||
unterschrift = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(get_unterschrift(docdata.Unterschrift_Rechts)); }
|
||||
if (unterschrift != "")
|
||||
{
|
||||
string ss = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(unterschrift);
|
||||
MemoryStream mssign = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(ss));
|
||||
MemoryStream mssign = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(unterschrift));
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
|
||||
mssign.Dispose();
|
||||
paragraph.AppendPicture(img);
|
||||
@@ -242,6 +280,10 @@ namespace DOCGEN.Klassen
|
||||
|
||||
if (dv.FieldName.ToString() != "")
|
||||
{
|
||||
if (dv.FieldName.ToString().Substring(0, 2) == "$$")
|
||||
{
|
||||
Replace_Text(ref document, dv.FieldName.ToString(),dv.Value.ToString());
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (WSection section in document.Sections)
|
||||
@@ -340,6 +382,7 @@ namespace DOCGEN.Klassen
|
||||
//document.UpdateDocumentFields();
|
||||
//document.UpdateAlternateChunks();
|
||||
|
||||
|
||||
|
||||
MemoryStream destms = new MemoryStream();
|
||||
if (formattype_original.ToString().ToUpper() == "DOTMXXX")
|
||||
@@ -504,10 +547,10 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
return baseEntity;
|
||||
}
|
||||
public Image resizeImage(Image imgToResize, Size size)
|
||||
{
|
||||
return (Image)(new Bitmap(imgToResize, size));
|
||||
}
|
||||
//public Image resizeImage(Image imgToResize, Size size)
|
||||
//{
|
||||
// return (Image)(new Bitmap(imgToResize, size));
|
||||
//}
|
||||
private static void FindAndReplaceInTable(WTable table, TextSelection textSelection)
|
||||
{
|
||||
//Iterate through the rows of table.
|
||||
@@ -534,6 +577,20 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
}
|
||||
|
||||
public void insert_ppfaktura(WordDocument document, string ppfakturaimage)
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
bookmarkNavigator.MoveToBookmark("TGEDKAdresseZustellungB99");
|
||||
string img = ppfakturaimage;
|
||||
byte[] b = Convert.FromBase64String(ppfakturaimage);
|
||||
MemoryStream mssign = new MemoryStream(b);
|
||||
System.Drawing.Image image = System.Drawing.Image.FromStream(mssign);
|
||||
IWParagraph paragraph = new WParagraph(document);
|
||||
paragraph.AppendPicture(image);
|
||||
bookmarkNavigator.InsertParagraph(paragraph);
|
||||
|
||||
}
|
||||
|
||||
public void Insert_Barcode(WordDocument document, clsDocData docData)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user