Update 2024-08-08
This commit is contained in:
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using DOCGEN.Klassen;
|
||||
//using DOCGEN.Klassen;
|
||||
using System.Security.Cryptography;
|
||||
using SkiaSharp;
|
||||
using System.Web;
|
||||
@@ -26,6 +26,11 @@ using Syncfusion.OfficeChart;
|
||||
using System.Drawing.Imaging;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Syncfusion.OfficeChartToImageConverter;
|
||||
using Syncfusion.XPS;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using Syncfusion.WinForms.ListView;
|
||||
|
||||
using Syncfusion.Windows.Forms.Tools;
|
||||
|
||||
namespace DocIO_Demo_SHU
|
||||
{
|
||||
@@ -42,7 +47,52 @@ namespace DocIO_Demo_SHU
|
||||
}
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Lic();
|
||||
|
||||
ImageList imageList = new ImageList { ImageSize = new Size(32, 32) };
|
||||
Image img = new Bitmap(Properties.Resources.Word_32x32_32);
|
||||
imageList.Images.Add(img);
|
||||
img = new Bitmap(Properties.Resources.Excel_32x32_32);
|
||||
imageList.Images.Add(img);
|
||||
img = new Bitmap(Properties.Resources.PDF_32x32_32);
|
||||
imageList.Images.Add(img);
|
||||
|
||||
//listView1.LargeImageList = imageList;
|
||||
////listView1.View = View.Tile;
|
||||
//listView1.Items.Add("Mahesh Chand");
|
||||
//listView1.Items.Add("Mike Gold");
|
||||
//listView1.Items.Add("Praveen Kumar");
|
||||
//listView1.Items.Add("Raj Beniwal");
|
||||
//listView1.AllowDrop = true;
|
||||
|
||||
//listView1.AllowDrop = true;
|
||||
//listView1.ItemDrag += new ItemDragEventHandler(myListView_ItemDrag);
|
||||
//listView1.DragEnter += new DragEventHandler(myListView_DragEnter);
|
||||
//listView1.DragOver += new DragEventHandler(myListView_DragOver);
|
||||
//listView1.DragLeave += new EventHandler(myListView_DragLeave);
|
||||
//listView1.DragDrop += new DragEventHandler(myListView_DragDrop);
|
||||
}
|
||||
private void myListView_ItemDrag(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
//listView1.DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
// Sets the target drop effect.
|
||||
private void myListView_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = e.AllowedEffect;
|
||||
}
|
||||
|
||||
// Moves the insertion mark as the item is dragged.
|
||||
|
||||
// Sorts ListViewItem objects by index.
|
||||
private class ListViewIndexComparer : System.Collections.IComparer
|
||||
{
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
return ((ListViewItem)x).Index - ((ListViewItem)y).Index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,133 +116,225 @@ namespace DocIO_Demo_SHU
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
string filename = @"x:\docdemo\FIN_VER_Kredit_OV928_019.dotm";
|
||||
using (WordDocument wordDocument = new WordDocument(filename, FormatType.Docx))
|
||||
{
|
||||
//Initialize the ChartToImageConverter for converting charts during Word to image conversion.
|
||||
wordDocument.ChartToImageConverter = new ChartToImageConverter();
|
||||
//Set the scaling mode for charts (Normal mode reduces the file size).
|
||||
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
|
||||
//Convert the entire Word document to images.
|
||||
Image[] images = wordDocument.RenderAsImages(ImageType.Bitmap);
|
||||
int i = 0;
|
||||
foreach (Image image in images)
|
||||
{
|
||||
//Save the image as jpeg.
|
||||
image.Save(@"x:\docdemo\WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
private void treeViewAdv1_ItemDrag(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
byte[] bytes = File.ReadAllBytes(textBox1.Text);
|
||||
string dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
|
||||
var streamword = new MemoryStream(Convert.FromBase64String(dokument));
|
||||
WordDocument document = new WordDocument(streamword, Syncfusion.DocIO.FormatType.Automatic);
|
||||
WordDocument newDocument = new WordDocument();
|
||||
WordDocument newDocument2 = new WordDocument();
|
||||
WordDocument newDocument3 = new WordDocument();
|
||||
string pdf = "";
|
||||
SynFWord sf = new SynFWord();
|
||||
DOCGEN.DocGet dg = new DOCGEN.DocGet("");
|
||||
|
||||
|
||||
|
||||
pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
File.WriteAllBytes(textBox1.Text + "_3_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
split_doc(ref document, ref newDocument, 1, 0);
|
||||
sf.Replace_Text(ref newDocument, "Bausteine", "");
|
||||
sf.Replace_Fieldtext(ref newDocument, "BesBest", "");
|
||||
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
newDocument.Save(outputStream,FormatType.Dotm);
|
||||
|
||||
bytes = outputStream.ToArray();
|
||||
dokument= Convert.ToBase64String(bytes);
|
||||
|
||||
//DOCGEN.DocGet dg = new DOCGEN.DocGet("");
|
||||
pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
File.WriteAllBytes(textBox1.Text + "_1_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
return;
|
||||
|
||||
//Vertrag Kunde
|
||||
split_doc(ref document, ref newDocument2, 2, 0);
|
||||
sf.Replace_Fieldtext(ref newDocument2, "BesBest", "");
|
||||
sf.Replace_Fieldtext(ref newDocument2, "txtDruckenExemplar", "den Kunden");
|
||||
newDocument2.UpdateDocumentFields();
|
||||
newDocument2.Save(outputStream, FormatType.Dotm);
|
||||
|
||||
bytes = outputStream.ToArray();
|
||||
dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
File.WriteAllBytes(textBox1.Text + "_2_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
//Vertrag Kunde
|
||||
split_doc(ref document, ref newDocument3, 2, 0);
|
||||
sf.Replace_Fieldtext(ref newDocument3, "BesBest", "");
|
||||
sf.Replace_Fieldtext(ref newDocument3, "txtDruckenExemplar", "den Kunden");
|
||||
newDocument3.UpdateDocumentFields();
|
||||
newDocument3.Save(outputStream, FormatType.Dotm);
|
||||
bytes = outputStream.ToArray();
|
||||
dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
File.WriteAllBytes(textBox1.Text + "_3_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//using (FileStream outputStream = new FileStream(textBox1.Text + "_1_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
//{
|
||||
// newDocument.Save(outputStream, FormatType.Dotm);
|
||||
//}
|
||||
|
||||
//int i = 0;
|
||||
//foreach (WSection section in document.Sections)
|
||||
//{
|
||||
// if (i != 0)
|
||||
// {
|
||||
// newDocument1.Sections.Add(document.Sections[i].Clone());
|
||||
// }
|
||||
// i = i + 1;
|
||||
//}
|
||||
//sf.Replace_Fieldtext(ref newDocument1, "txtDruckenExemplar", "den Kunden");
|
||||
//sf.Replace_Text(ref newDocument1, "Bausteine", "");
|
||||
//newDocument1.UpdateDocumentFields();
|
||||
|
||||
//using (FileStream outputStream = new FileStream(textBox1.Text + "_2_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
//{
|
||||
// newDocument1.Save(outputStream, FormatType.Dotm);
|
||||
//}
|
||||
//sf.Replace_Fieldtext(ref newDocument1, "txtDruckenExemplar", "die Bank");
|
||||
|
||||
//newDocument1.UpdateDocumentFields();
|
||||
|
||||
//using (FileStream outputStream = new FileStream(textBox1.Text + "_3_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
//{
|
||||
// newDocument1.Save(outputStream, FormatType.Dotm);
|
||||
//}
|
||||
private void treeViewAdv1_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
|
||||
}
|
||||
private void treeView1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void treeViewAdv1_ItemDrag_1(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
TreeViewAdv treeViewAdv = sender as TreeViewAdv;
|
||||
|
||||
// The TreeViewAdv always provides an array of selected nodes.
|
||||
TreeNodeAdv[] nodes = e.Item as TreeNodeAdv[];
|
||||
|
||||
// Let us get only the first selected node.
|
||||
TreeNodeAdv node = nodes[0];
|
||||
DragDropEffects result = treeViewAdv.DoDragDrop(node, DragDropEffects.Move);
|
||||
}
|
||||
private TreeNodeAdv currentSourceNode;
|
||||
private void treeViewAdv1_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
bool droppable = true;
|
||||
TreeNodeAdv destinationNode = null;
|
||||
TreeViewAdv treeView = sender as TreeViewAdv;
|
||||
Point ptInTree = treeView.PointToClient(new Point(e.X, e.Y));
|
||||
this.currentSourceNode = null;
|
||||
|
||||
// Looking for a single tree node.
|
||||
if (e.Data.GetDataPresent(typeof(TreeNodeAdv)))
|
||||
{
|
||||
// Get the destination and source node.
|
||||
destinationNode = treeView.GetNodeAtPoint(ptInTree);
|
||||
TreeNodeAdv sourceNode = (TreeNodeAdv)e.Data.GetData(typeof(TreeNodeAdv));
|
||||
this.currentSourceNode = sourceNode;
|
||||
droppable = true;
|
||||
}
|
||||
else
|
||||
droppable = false;
|
||||
if (droppable)
|
||||
// If Moving is allowed:
|
||||
e.Effect = DragDropEffects.Move;
|
||||
else
|
||||
e.Effect = DragDropEffects.None;
|
||||
Point pt = this.treeViewAdv1.PointToClient(new Point(e.X, e.Y));
|
||||
this.treeViewAdv1.SelectedNode = this.treeViewAdv1.GetNodeAtPoint(pt);
|
||||
Console.WriteLine(this.treeViewAdv1.SelectedNode.Text);
|
||||
}
|
||||
|
||||
private void treeViewAdv1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
TreeViewAdv treeView = sender as TreeViewAdv;
|
||||
// Get the destination and source node.
|
||||
TreeNodeAdv sourceNode = (TreeNodeAdv)e.Data.GetData(typeof(TreeNodeAdv));
|
||||
Point pt = this.treeViewAdv1.PointToClient(new Point(e.X, e.Y));
|
||||
TreeNodeAdv destinationNode = this.treeViewAdv1.GetNodeAtPoint(pt);
|
||||
sourceNode.Move(destinationNode, NodePositions.Next);
|
||||
this.currentSourceNode = null;
|
||||
treeView.SelectedNode = sourceNode;
|
||||
}
|
||||
|
||||
private void treeViewAdv1_DragLeave(object sender, EventArgs e)
|
||||
{
|
||||
//this.treeViewDragHighlightTracker.ClearHighlightNode();
|
||||
}
|
||||
|
||||
private void treeViewAdv1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
|
||||
{
|
||||
if (e.EscapePressed)
|
||||
{
|
||||
e.Action = DragAction.Cancel;
|
||||
}
|
||||
}
|
||||
|
||||
private void treeViewAdv1_DragEnter_1(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//private void button1_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// string filename = @"x:\docdemo\FIN_VER_Kredit_OV928_019.dotm";
|
||||
// using (WordDocument wordDocument = new WordDocument(filename, FormatType.Docx))
|
||||
// {
|
||||
// //Initialize the ChartToImageConverter for converting charts during Word to image conversion.
|
||||
// wordDocument.ChartToImageConverter = new ChartToImageConverter();
|
||||
// //Set the scaling mode for charts (Normal mode reduces the file size).
|
||||
// wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
|
||||
// //Convert the entire Word document to images.
|
||||
// Image[] images = wordDocument.RenderAsImages(ImageType.Bitmap);
|
||||
// int i = 0;
|
||||
// foreach (Image image in images)
|
||||
// {
|
||||
// //Save the image as jpeg.
|
||||
// image.Save(@"x:\docdemo\WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
|
||||
// i++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return;
|
||||
|
||||
|
||||
|
||||
|
||||
// byte[] bytes = File.ReadAllBytes(textBox1.Text);
|
||||
// string dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
|
||||
// var streamword = new MemoryStream(Convert.FromBase64String(dokument));
|
||||
// WordDocument document = new WordDocument(streamword, Syncfusion.DocIO.FormatType.Automatic);
|
||||
// WordDocument newDocument = new WordDocument();
|
||||
// WordDocument newDocument2 = new WordDocument();
|
||||
// WordDocument newDocument3 = new WordDocument();
|
||||
// string pdf = "";
|
||||
// SynFWord sf = new SynFWord();
|
||||
// DOCGEN.DocGet dg = new DOCGEN.DocGet("");
|
||||
|
||||
|
||||
|
||||
// pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
// File.WriteAllBytes(textBox1.Text + "_3_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
// split_doc(ref document, ref newDocument, 1, 0);
|
||||
// sf.Replace_Text(ref newDocument, "Bausteine", "");
|
||||
// sf.Replace_Fieldtext(ref newDocument, "BesBest", "");
|
||||
|
||||
// MemoryStream outputStream = new MemoryStream();
|
||||
// newDocument.Save(outputStream,FormatType.Dotm);
|
||||
|
||||
// bytes = outputStream.ToArray();
|
||||
// dokument= Convert.ToBase64String(bytes);
|
||||
|
||||
// //DOCGEN.DocGet dg = new DOCGEN.DocGet("");
|
||||
// pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
// File.WriteAllBytes(textBox1.Text + "_1_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
// return;
|
||||
|
||||
// //Vertrag Kunde
|
||||
// split_doc(ref document, ref newDocument2, 2, 0);
|
||||
// sf.Replace_Fieldtext(ref newDocument2, "BesBest", "");
|
||||
// sf.Replace_Fieldtext(ref newDocument2, "txtDruckenExemplar", "den Kunden");
|
||||
// newDocument2.UpdateDocumentFields();
|
||||
// newDocument2.Save(outputStream, FormatType.Dotm);
|
||||
|
||||
// bytes = outputStream.ToArray();
|
||||
// dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
// pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
// File.WriteAllBytes(textBox1.Text + "_2_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
// //Vertrag Kunde
|
||||
// split_doc(ref document, ref newDocument3, 2, 0);
|
||||
// sf.Replace_Fieldtext(ref newDocument3, "BesBest", "");
|
||||
// sf.Replace_Fieldtext(ref newDocument3, "txtDruckenExemplar", "den Kunden");
|
||||
// newDocument3.UpdateDocumentFields();
|
||||
// newDocument3.Save(outputStream, FormatType.Dotm);
|
||||
// bytes = outputStream.ToArray();
|
||||
// dokument = Convert.ToBase64String(bytes);
|
||||
|
||||
// pdf = dg.Convert_Word_To_PDF(dokument, null);
|
||||
// File.WriteAllBytes(textBox1.Text + "_3_" + ".pdf", Convert.FromBase64String(pdf));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //using (FileStream outputStream = new FileStream(textBox1.Text + "_1_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
// //{
|
||||
// // newDocument.Save(outputStream, FormatType.Dotm);
|
||||
// //}
|
||||
|
||||
// //int i = 0;
|
||||
// //foreach (WSection section in document.Sections)
|
||||
// //{
|
||||
// // if (i != 0)
|
||||
// // {
|
||||
// // newDocument1.Sections.Add(document.Sections[i].Clone());
|
||||
// // }
|
||||
// // i = i + 1;
|
||||
// //}
|
||||
// //sf.Replace_Fieldtext(ref newDocument1, "txtDruckenExemplar", "den Kunden");
|
||||
// //sf.Replace_Text(ref newDocument1, "Bausteine", "");
|
||||
// //newDocument1.UpdateDocumentFields();
|
||||
|
||||
// //using (FileStream outputStream = new FileStream(textBox1.Text + "_2_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
// //{
|
||||
// // newDocument1.Save(outputStream, FormatType.Dotm);
|
||||
// //}
|
||||
// //sf.Replace_Fieldtext(ref newDocument1, "txtDruckenExemplar", "die Bank");
|
||||
|
||||
// //newDocument1.UpdateDocumentFields();
|
||||
|
||||
// //using (FileStream outputStream = new FileStream(textBox1.Text + "_3_" + ".dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
// //{
|
||||
// // newDocument1.Save(outputStream, FormatType.Dotm);
|
||||
// //}
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user