首页 文章

使用Aspose.Words将docx转换为图像

提问于
浏览
1

我正在将生成的文档转换为pdf和png,请参阅下面的代码 . 但由于某些原因,字体有问题 . 在我的本地开发机器上,一切都是正确的,但是当部署在 生产环境 服务器上时,PNG中的字体丢失了 . 我已经检查过,但它们已安装在服务器上 . 有人可以帮我弄这个吗?

var dstDoc = doc.Clone();
var newInvoice = new InvoicePdf(factuur);
var ds = newInvoice.ToDataSet();
dstDoc.BuiltInDocumentProperties.Title = newInvoice.InvoiceID;
dstDoc.BuiltInDocumentProperties.Subject = newInvoice.SendDate;
dstDoc.MailMerge.FieldMergingCallback = new HandleMergeFieldAlternatingRows();
dstDoc.MailMerge.ExecuteWithRegions(ds);

var filePath = Path.Combine(folderInvoices, newInvoice.SendDateOrginal.Year.ToString(CultureInfo.InvariantCulture));
Directory.CreateDirectory(filePath);
var fileName = string.Format("{0} - {1}", newInvoice.InvoiceID, newInvoice.DebtorCompany.ToString(true));
filePath = Path.Combine(filePath, fileName);
filePaths.Add(filePath + ".pdf");
dstDoc.Save(filePath + ".pdf", SaveFormat.Pdf);

var options = new ImageSaveOptions(SaveFormat.Png) { PageCount = 1, Resolution = 120, UseAntiAliasing = true, PrettyFormat = true, UseHighQualityRendering = true };
for (var i = 0; i < dstDoc.PageCount; i++)
{
    options.PageIndex = i;
    dstDoc.Save(string.Format("{0}_{1}.png", filePath, i), options);
}

1 回答

相关问题