获取模板使用word编辑完成后转换成pdf文件预览 然后打印 使用
FileResult 来打印Aspose.Words;
public FileResult PrintFile(string filePath)
{
Document doc;//创建文件
string FilePathTemp;
if (string.IsNullOrWhiteSpace(filePath))
{
FilePathTemp = Server.MapPath("../TempFiles/AAABB.doc");
}
else
{
FilePathTemp = filePath;
}
doc = new Document(FilePathTemp);//导入模板文件
MemoryStream memoryStream = new MemoryStream();
// 写入数据
doc.Save(memoryStream, Aspose.Words.SaveFormat.Pdf);//保存到缓存中
memoryStream.Seek(0, SeekOrigin.Begin);//处理从第一个字节开始
var fileResult = new FileStreamResult(memoryStream, "application/octet-stream")
{
FileDownloadName = "PrintFile.pdf"
};
return fileResult;
}