We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Words word转pdf 图片丢失

问题描述:程序在windows环境中是正常的,在Linux环境下有这个问题,用得是Aspose.Words.dll这个插件,Word转PDF,图标丢失。
核心代码:

var oldPath = Path.Combine(_hostingEnvironment.WebRootPath, "WordTemplate.doc");
var newPath = Path.Combine(_hostingEnvironment.WebRootPath, "PDFTemplate.pdf");
Console.WriteLine("开始word转pdf");

WordToPdf(oldPath, newPath);

Console.WriteLine("结束word转pdf");

WordToPdf方法:

public static void WordToPdf(string wordPath, string pdfPath)
{
    try
    {
        //Aspose.Words.License lic = new Aspose.Words.License();
        //lic.SetLicense("Aspose.Total.lic");破解版不用设置license
        //打开word文件
        Document doc = new Aspose.Words.Document(wordPath);
        //验证参数
        if (doc == null) { throw new Exception("Word文件无效"); }
        doc.Save(pdfPath, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
    }
}

WordTemplate.doc模板文件附件:

转化之后的PDF文件:PDFTemplate.pdf (134.7 KB)

@billwu

您可以ZIP并在此处附加输入的Word文档以进行测试吗? 我们将对此问题进行调查,并为您提供更多信息。