如何使用C#.Net将单词转换为pdf [英] How to convert word to pdf using C#.Net

查看:106
本文介绍了如何使用C#.Net将单词转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用第三方dll文件准备优惠...

这是我的代码..

I want to prepare Offer using Third party dll file...
Here is my code..

protected void Page_Load(object sender, EventArgs e)
  {
      Spire.Doc.Document document = new Spire.Doc.Document();
      document.LoadFromFile(Server.MapPath("~\\Vijju offer letter.docx"));

      //Convert to PDF and Launch PDF
      document.SaveToFile("Word2PDF.PDF", FileFormat.PDF);
      System.Diagnostics.Process.Start("Word2PDF.PDF");
  }



我在第二行


I got an exception at second line "

Current file path is not exits.



但是我有一个.docx文件..但是它显示了一个例外..

请帮帮我...

在此先感谢..


but i have a .docx file..but it shows an exception..
please help me...
Thanks In Advance..

推荐答案

查看此链接



how-do-i-convert-word-files-to-pdf-programmatically [ ^ ]



convert-doc-to-pdf-in-c-sharp [ ^ ]



希望它会有所帮助..
Check this links

how-do-i-convert-word-files-to-pdf-programmatically[^]

convert-doc-to-pdf-in-c-sharp[^]

Hope it will help..






您可以尝试将.doc文件放在包含.csproj的文件夹中,然后使用




You can try to put your .doc file in folder that contains .csproj, then load the file using

document.LoadFromFile(Server.MapPath("~\\Vijju offer letter.docx"));





或者通过相对路径直接加载.doc文件





Or load the .doc file directly by its relative path

document.LoadFromFile(@"E:\..\..\Vijju offer letter.docx");


您的路径必须是全名,也包括您的文档。试试这个;



Your path must be full name consist of your doc also. Try this;

private string path = @"D:\archemendo\doc\";
private string fileName_word1 = "Arche.docx";

public void WordTest() 
{
   document.LoadFromFile(path + fileName_word1);
   RunWordFile(path + fileName_word1);
}

public void RunWordFile(string fileName) {
try 
{
  System.Diagnostics.Process.Start(fileName);
}
catch(Exception ex)
{
  return;
}
}


这篇关于如何使用C#.Net将单词转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆