update 20250921
This commit is contained in:
@@ -227,6 +227,46 @@ namespace DOCGEN.Klassen
|
||||
// signature.OwnerParagraph.AppendPicture(img);
|
||||
mssign = null;
|
||||
}
|
||||
void InsertBookmark(WordDocument document, WParagraph paragraph, string name)
|
||||
{
|
||||
BookmarkStart bookmarkStart = new BookmarkStart(document, name);
|
||||
BookmarkEnd bookmarkEnd = new BookmarkEnd(document, name);
|
||||
paragraph.ChildEntities.Insert(0, bookmarkStart);
|
||||
paragraph.ChildEntities.Add(bookmarkEnd);
|
||||
}
|
||||
void AddBookmarkToHeaderFooter(WordDocument document, HeaderFooter headerFooter, string bookmarkName)
|
||||
{
|
||||
int bookmarkIndex = 1; // Counter to ensure unique bookmark names
|
||||
|
||||
if (headerFooter.ChildEntities.Count > 0)
|
||||
{
|
||||
foreach (Entity childEntity in headerFooter.ChildEntities)
|
||||
{
|
||||
if (childEntity is WParagraph paragraph && paragraph.ChildEntities.Count > 0)
|
||||
{
|
||||
InsertBookmark(document, paragraph, bookmarkName + bookmarkIndex);
|
||||
bookmarkIndex++;
|
||||
}
|
||||
else if (childEntity is WTable table)
|
||||
{
|
||||
foreach (WTableRow row in table.Rows)
|
||||
{
|
||||
foreach (WTableCell cell in row.Cells)
|
||||
{
|
||||
foreach (Entity cellEntity in cell.ChildEntities)
|
||||
{
|
||||
if (cellEntity is WParagraph cellParagraph && cellParagraph.ChildEntities.Count > 0)
|
||||
{
|
||||
InsertBookmark(document, cellParagraph, bookmarkName + bookmarkIndex);
|
||||
bookmarkIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Generate_Word(string base64, clsDocData docdata, string img_UL = "", string img_UR = "", string img_faktura = "", bool serienbrief = false, bool editdoc = false)
|
||||
{
|
||||
|
||||
@@ -285,7 +325,7 @@ namespace DOCGEN.Klassen
|
||||
insert_Logo(document, docdata);
|
||||
}
|
||||
|
||||
if (docdata.Kopfzeile_generieren == true)
|
||||
if (docdata.Kopfzeile_generieren)// == true && editdoc==false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -297,20 +337,33 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
foreach (WSection section in document.Sections)
|
||||
{
|
||||
IWParagraph p;
|
||||
|
||||
p = section.HeadersFooters.FirstPageHeader.AddParagraph();
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
try
|
||||
{
|
||||
if (dv.TMBeginn.ToString() == "TGEDKCompanyBBEB99")
|
||||
{
|
||||
p.AppendText(dv.Value);
|
||||
}
|
||||
|
||||
p = section.HeadersFooters.FirstPageHeader.Paragraphs[section.HeadersFooters.FirstPageHeader.Paragraphs.Count - 1];
|
||||
|
||||
}
|
||||
p.AppendBookmarkStart("TGEDKCompanyBBEB99");
|
||||
p.AppendBreak(BreakType.LineBreak);
|
||||
catch { p = section.HeadersFooters.FirstPageHeader.AddParagraph(); }
|
||||
|
||||
|
||||
BookmarkStart bookmarkStart = new BookmarkStart(document, "TGEDKCompanyBBEB99");
|
||||
BookmarkEnd bookmarkEnd = new BookmarkEnd(document, "TGEDKCompanyBBEB99");
|
||||
p.ChildEntities.Insert(0, bookmarkStart);
|
||||
p.ChildEntities.Add(bookmarkEnd);
|
||||
|
||||
//foreach (clsDocValue dv in docdata.DocValues)
|
||||
//{
|
||||
// if (dv.TMBeginn.ToString() == "TGEDKCompanyBBEB99")
|
||||
// {
|
||||
// p.AppendText(dv.Value);
|
||||
// }
|
||||
//}
|
||||
//p.AppendBookmarkStart("TGEDKCompanyBBEB99");
|
||||
//p.AppendBreak(BreakType.LineBreak);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user