[英]Drawings disappear after convert from word to pdf with Interop.Word
[英]Convert from word to pdf
怎么把word轉成pdf。
using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using Xceed.Words.NET;
using Microsoft.Office.Interop.Word;
public partial class new_test : Form
{
public new_test()
{
InitializeComponent();
}
public Microsoft.Office.Interop.Word.Document WordDocument { get; private set; }
private void button1_Click(object sender, EventArgs e)
{
var doc = DocX.Load("C:\\Users\\IT-TEAM\\Desktop\\text0\\tm.docx");
doc.SaveAs("C:\\Users\\IT-TEAM\\Desktop\\text0\\" + textBox1.Text + ".docx");
Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
WordDocument = appWord.Documents.Open("C:\\Users\\IT-TEAM\\Desktop\\text0\\" + textBox1.Text + ".docx");
WordDocument.ExportAsFixedFormat("C:\\Users\\IT-TEAM\\Desktop\\text0\\" + textBox1.Text + ".pdf", WdExportFormat.wdExportFormatPDF);
我使用此代碼,但每次它在任務管理器中保存單詞 show 時仍然使用我試過的單詞
WordDocument.Close();
仍然顯示在任務管理器中
試試這個代碼。
public partial class Page: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
wordDocument = appWord.Documents.Open(@"C:\\Users\\IT-TEAM\\text0\\y" + textBox1.Text + ".docx");
wordDocument.ExportAsFixedFormat(@"C:\\Users\\IT-TEAM\\y" + textBox1.Text + ".pdf", WdExportFormat.wdExportFormatPDF);
}
public Microsoft.Office.Interop.Word.Document wordDocument { get; set; }
}
}
您不想編寫轉換代碼。現在,市場上有幾個saas 模型API 庫。 PDF4me 提供了一個 API 集合,您可以嘗試一下。 [ https://developer.pdf4me.com/ ]:https://developer.pdf4me.com/ 。
它為您提供了 Javascript 和 C# 庫,非常經濟且可靠。 通過使用這些工具,您可以降低開發和基礎架構成本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.