update 20250317
This commit is contained in:
@@ -29,6 +29,8 @@ using Syncfusion.CompoundFile.DocIO;
|
||||
using Helper;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using System.Data.Common;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
|
||||
|
||||
namespace OnDocOffice
|
||||
@@ -1914,5 +1916,50 @@ namespace OnDocOffice
|
||||
|
||||
}
|
||||
|
||||
public class OfficeToPDF
|
||||
{
|
||||
public string word_to_pdf(string dokumentid,string connectionstring,string tempdir)
|
||||
{
|
||||
DB db=new DB(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "", "");
|
||||
dok = db.GetDocumentAsBase64(dokumentid);
|
||||
string SQL = "SELECT dbo.dokumenttyp.ErstellungInOffice FROM dbo.dokument INNER JOIN dbo.dokumenttyp ON dbo.dokument.dokumenttypnr = dbo.dokumenttyp.dokumenttypnr where dbo.dokument.dokumentid=@dokumentid";
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", dokumentid);
|
||||
db.Get_Tabledata_Addvar(SQL, false, true);
|
||||
if (Convert.ToBoolean(db.dsdaten.Tables[0].Rows[0]["Erstellunginoffice"]))
|
||||
{
|
||||
return convert_word_to_pdf(ref dok,tempdir,dokumentid);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DOCGEN.DocGet dg = new DOCGEN.DocGet(connectionstring);
|
||||
dok = dg.GetDocAsPDF(dokumentid);
|
||||
dg = null;
|
||||
return dok.dokument;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string convert_word_to_pdf(ref clsdok dok,string tempdir,string dokumentid)
|
||||
{
|
||||
clsFileHelper fh = new clsFileHelper();
|
||||
string filename=tempdir+ DateTime.Now.ToString("yyyyMMddhhmmss")+"_"+dokumentid+dok.extension;
|
||||
string outputfile = filename + ".pdf";
|
||||
fh.SaveBase64ToFile(dok.dokument, filename);
|
||||
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
|
||||
Microsoft.Office.Interop.Word.Document worddoc = new Microsoft.Office.Interop.Word.Document();
|
||||
worddoc= word.Documents.Open(filename);
|
||||
worddoc.ExportAsFixedFormat(outputfile.ToString(), Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, false, Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument,0,99, Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent, true, true, Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, true, true, false);
|
||||
|
||||
worddoc.Close(false);
|
||||
word.Quit(false);
|
||||
worddoc = null;
|
||||
word = null;
|
||||
return fh.Base64FromFile(outputfile);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user