You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.9 KiB
112 lines
3.9 KiB
using Syncfusion.DocIO;
|
|
using Syncfusion.DocIO.DLS;
|
|
|
|
using System.IO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml.Linq;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace DocIO_Demo_SHU
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void Lic()
|
|
{
|
|
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NCaF5cXmZCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWXdecXRdQ2heUU13XUI=");
|
|
}
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
Lic();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
using (WordDocument document = new WordDocument(textBox1.Text))
|
|
{
|
|
int fileId = 1;
|
|
|
|
foreach (WSection section in document.Sections)
|
|
{
|
|
//Create new Word document
|
|
using (WordDocument newDocument = new WordDocument())
|
|
{
|
|
//Add cloned section into new Word document
|
|
newDocument.Sections.Add(section.Clone());
|
|
//Saves the Word document to MemoryStream
|
|
using (FileStream outputStream = new FileStream(textBox1.Text + fileId + ".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
|
{
|
|
newDocument.Save(outputStream, FormatType.Dotm);
|
|
}
|
|
}
|
|
fileId++;
|
|
}
|
|
return;
|
|
|
|
document.Open(textBox1.Text);
|
|
document.UpdateDocumentFields();
|
|
document.Save(textBox1.Text + ".dotm");
|
|
try
|
|
{
|
|
foreach (WSection section in document.Sections)
|
|
//Iterates through section child elements
|
|
foreach (WTextBody textBody in section.ChildEntities)
|
|
{
|
|
//Iterates through form fields
|
|
foreach (WFormField formField in textBody.FormFields)
|
|
{
|
|
if (formField.Name == "txtDruckenExemplar")
|
|
{
|
|
formField.Text = "für die Bank";
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
catch { }
|
|
try
|
|
{
|
|
foreach (WSection section in document.Sections)
|
|
//Iterates through section child elements
|
|
foreach (WTextBody textBody in section.ChildEntities)
|
|
{
|
|
//Iterates through form fields
|
|
foreach (WFormField formField in textBody.FormFields)
|
|
{
|
|
if (formField.Name == "BesBest")
|
|
{
|
|
formField.Text = "";
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
//BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
|
//bookmarkNavigator.MoveToBookmark("txtDruckenExemplar");
|
|
//bookmarkNavigator.InsertText("für die anderen");
|
|
document.UpdateDocumentFields();
|
|
document.Save(textBox1.Text + ".dotm.dotm");
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|