Update 20260529

This commit is contained in:
Stefan Hutter
2026-05-29 12:25:25 +02:00
parent 6d764dccd0
commit 42376fc823
35 changed files with 7025 additions and 86 deletions
+65 -9
View File
@@ -49,6 +49,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;
using System.Drawing.Drawing2D;
@@ -1011,7 +1012,14 @@ namespace DOCGEN.Klassen
return dest;// bmp.Save(outputPath, jpgEncoder, encParams);
}
}
public static System.Drawing.Image resizeImage1(System.Drawing.Image image, int new_height, int new_width)
{
Bitmap new_image = new Bitmap(new_width, new_height);
Graphics g = Graphics.FromImage((System.Drawing.Image)new_image);
g.InterpolationMode = InterpolationMode.High;
g.DrawImage(image, 0, 0, new_width, new_height);
return new_image;
}
private void Insert_CLMImages(CLMDocItem item, ref WordDocument document, Boolean inline = false)
{
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
@@ -1032,15 +1040,31 @@ namespace DOCGEN.Klassen
dt = (DataTable)JsonConvert.DeserializeObject(item.itemvalue, (typeof(DataTable)));
foreach (DataRow dr in dt.Rows)
{
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(dr[0].ToString()));
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
if (Convert.ToInt32(item.width) != 0 || Convert.ToInt32(item.height) != 0)
{
// img = Resize(img, Convert.ToInt32(item.width), Convert.ToInt32(item.width)), true, true);
img = Resize1(img, "", Convert.ToInt32(item.width), Convert.ToInt32(item.height));
}
paragraph.AppendPicture(img);
MemoryStream mssign = new MemoryStream(Convert.FromBase64String(dr[0].ToString()));
System.Drawing.Image img = System.Drawing.Image.FromStream(mssign);
WPicture picture = paragraph.AppendPicture(img) as WPicture;
IWSection section = document.Sections[0];
float clientWidth = section.PageSetup.ClientWidth;
float clientHeight = section.PageSetup.PageSize.Height - section.PageSetup.Margins.Top - section.PageSetup.Margins.Bottom;
float scalePer = 0;
if (Convert.ToInt32(item.width)>0) { clientWidth = Convert.ToInt32(item.width); }
if (picture.Width > clientWidth)
{
scalePer = clientWidth / img.Width * 100;
}
else if (picture.Height > clientHeight)
{
scalePer = clientHeight / img.Height * 100;
}
picture.WidthScale = scalePer;
picture.HeightScale = scalePer;
mssign = null;
img = null;
}
@@ -1048,6 +1072,7 @@ namespace DOCGEN.Klassen
paragraph = null;
bookmarkNavigator = null;
dt = null;
//document.Save(@"x:\doc.docx");
}
catch (Exception ex)
{
@@ -1112,6 +1137,37 @@ namespace DOCGEN.Klassen
mssign = null;
signature = null;
}
public System.Drawing.Image ResizeImageG(System.Drawing.Image inputimg, int targetWidth, int targetHeight, long jpegQuality = 85L)
{
// 1. Ursprungsbild laden
using (System.Drawing.Image originalImage = inputimg)
{
// 2. Ziel-Bitmap mit den neuen Maßen erstellen
using (Bitmap destImage = new Bitmap(targetWidth, targetHeight))
{
// Auflösung beibehalten (wichtig für die Druckqualität)
destImage.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution);
// 3. Graphics-Objekt für höchste Qualität konfigurieren
using (Graphics graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
// Bild auf das neue Graphics-Objekt zeichnen
graphics.DrawImage(originalImage, new Rectangle(0, 0, targetWidth, targetHeight),
new Rectangle(0, 0, originalImage.Width, originalImage.Height),
GraphicsUnit.Pixel);
return destImage;
}
}
}
}
private void Insert_CLMImage(CLMDocItem item, ref WordDocument document, Boolean inline = false, Boolean multiimages = false)
{
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.