Upsdate 20240729
This commit is contained in:
37
OfficePrinter/Class1.cs
Normal file
37
OfficePrinter/Class1.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
|
||||
|
||||
namespace OfficePrinter
|
||||
{
|
||||
public class OnDocOffice
|
||||
|
||||
{
|
||||
//Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
|
||||
|
||||
public void PrintWordToPDF(string filename, string pdfname)
|
||||
{
|
||||
Application appWord = new Application();
|
||||
Microsoft.Office.Interop.Word.Document wordDocument = new Microsoft.Office.Interop.Word.Document();
|
||||
wordDocument = appWord.Documents.Open(filename);
|
||||
appWord.Visible = true;
|
||||
wordDocument.PrintOut(
|
||||
OutputFileName: pdfname,
|
||||
PrintToFile: true);
|
||||
wordDocument.Close();
|
||||
wordDocument = null;
|
||||
appWord.Quit(SaveChanges: false);
|
||||
appWord = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user