【问题标题】:iTextSharp to WordiTextSharp 到 Word
【发布时间】:2015-05-06 17:44:50
【问题描述】:

我在我的 MVC 应用程序中使用 iTextSharp 创建一个 .pdf 文件,但有没有办法将它转换为一个 .doc 文件?

public ActionResult Download(int? Id)
    {
        string FileName = "Test";

        var FilePath = Path.Combine(Path.GetTempPath(), "Temp.pdf");

        Document UserPDF = new Document();
        PdfWriter.GetInstance(UserPDF, new FileStream(FilePath, FileMode.Create));

        CreateCv(UserPDF); // This is where the PDF is created

        var fs = new FileStream(FilePath, FileMode.Open);
        var Bytes = new byte[fs.Length];
        fs.Read(Bytes, 0, (int)fs.Length);
        fs.Close();

        return File(Bytes, "application/pdf", FileName + ".pdf");
    }

【问题讨论】:

标签: c# asp.net-mvc itextsharp


【解决方案1】:

简单地说,不。无法使用 iTextSharp 将其转换为 DOC 文件。只支持PDF文件的读取和生成。

使用其他一些第三方库可以将 PDF 转换为 DOC,但目前还没有可靠的方法(并保留格式/空白)。如果您在网上搜索,人们建议从 PDF 创建图像,然后将图像附加到空白 DOC 文件的末尾(这是一个主要的 hack)。

【讨论】:

  • 这是 100% 正确的。我希望答案被接受,因为“不,那不可能”是一个有效的答案,但也是一个通常不受欢迎的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-29
  • 2015-03-21
  • 2011-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多