Update 20240706
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Data;
|
||||
using Model;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using System.Security.Policy;
|
||||
|
||||
namespace DOCGEN.Generator
|
||||
{
|
||||
@@ -71,6 +72,7 @@ namespace DOCGEN.Generator
|
||||
|
||||
//db.get_vorlage_to_file(db.dsdaten.Tables[0].Rows[0][1].ToString(),tempdir,dokumentid );
|
||||
}
|
||||
|
||||
|
||||
public void generate_docdata(string dokumentid, ref clsDocData docdata)
|
||||
{
|
||||
@@ -101,5 +103,12 @@ namespace DOCGEN.Generator
|
||||
}
|
||||
docdata.DocMacros = docMacros;
|
||||
}
|
||||
public void DocToPDF(ref clsdok dok )
|
||||
{
|
||||
SynFWord sfword = new SynFWord();
|
||||
dok.dokument = sfword.DocToPDF(dok.dokument);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ using Syncfusion.DocToPDFConverter;
|
||||
using Syncfusion.Pdf;
|
||||
using System.Management.Instrumentation;
|
||||
using Syncfusion.XlsIO.FormatParser.FormatTokens;
|
||||
using System.Security.Policy;
|
||||
using System.Buffers.Text;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
@@ -420,22 +422,75 @@ namespace DOCGEN.Klassen
|
||||
section.HeadersFooters.Footer.AddParagraph().ChildEntities.Add(picture);
|
||||
section.HeadersFooters.FirstPageFooter.AddParagraph().ChildEntities.Add(picture2);
|
||||
|
||||
//IWParagraph paragraph = section.AddParagraph();
|
||||
//paragraph.AppendPicture(imageStream);
|
||||
|
||||
//PictureWatermark picWatermark = new PictureWatermark();
|
||||
//picWatermark.Scaling = 120f;
|
||||
//picWatermark.Washout = false;
|
||||
//document.Watermark = picWatermark;
|
||||
//FileStream WatermarkStream = new FileStream(@"x:\docdemo\bc.jpg", FileMode.Open, FileAccess.Read);
|
||||
//BinaryReader br = new BinaryReader(WatermarkStream);
|
||||
//byte[] image = br.ReadBytes((int)WatermarkStream.Length);
|
||||
////Sets the image to the picture watermark.
|
||||
//picWatermark.LoadPicture(image);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public string DocToPDF(string dokument)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(dokument));
|
||||
WordDocument document = new WordDocument(ms, FormatType.Automatic);
|
||||
|
||||
int i = 0;
|
||||
//Iterate each section from Word document
|
||||
foreach (WSection section in document.Sections)
|
||||
{
|
||||
//Create new Word document
|
||||
WordDocument newDocument = new WordDocument();
|
||||
//Add cloned section into new Word document
|
||||
newDocument.Sections.Add(section.Clone());
|
||||
//Saves the Word document to MemoryStream
|
||||
FileStream outputStream = new FileStream(@"x:\T1.totm", FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
newDocument.Save(outputStream, FormatType.Dotm);
|
||||
document.Sections.RemoveAt(i);
|
||||
FileStream outputStream1 = new FileStream(@"x:\T2.dotm", FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
document.Save(outputStream1, FormatType.Dotm);
|
||||
|
||||
newDocument.Close();
|
||||
document.Close();
|
||||
outputStream.Close();
|
||||
outputStream1.Close();
|
||||
i++;
|
||||
}
|
||||
return "";
|
||||
|
||||
|
||||
//int cnt = document.Sections.Count;
|
||||
//TextSelection textSelection = document.Find("Exemplar für", false, true);
|
||||
//return dokument;
|
||||
}
|
||||
|
||||
public int GetPageNumber(string text, WordDocument wd)
|
||||
{
|
||||
//DocToPDFConverter converter = new DocToPDFConverter();
|
||||
//PdfDocument pdfDocument = converter.ConvertToPDF(wd);
|
||||
//MemoryStream stream = new MemoryStream();
|
||||
//pdfDocument.Save(stream);
|
||||
//pdfDocument.Close(true);
|
||||
//wd.Close();
|
||||
//converter.Dispose();
|
||||
//stream.Position = 0;
|
||||
|
||||
//FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
|
||||
//stream.CopyTo(fileStream);
|
||||
//fileStream.Close();
|
||||
|
||||
//PdfViewerControl documentViewer = new PdfViewerControl();
|
||||
////Load the PDF document
|
||||
//documentViewer.Load(stream);
|
||||
|
||||
////Get the occurrences of the target text and location.
|
||||
//Dictionary<int, List<RectangleF>> textSearch = new Dictionary<int, List<RectangleF>>();
|
||||
//bool IsMatchFound = documentViewer.FindText("Revision History", out textSearch);
|
||||
//List<int> pageNumbers = null;
|
||||
//if (IsMatchFound)
|
||||
//{
|
||||
// pageNumbers = GetPageNumebers(textSearch);
|
||||
//}
|
||||
//documentViewer.Dispose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user