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);
}
4

1 回答 1

0

如果它是共享服务器,那么很可能是安全问题。Aspose.Words for .NET DLL 需要访问 Windows 注册表才能找到字体文件夹。有关详细信息,请参阅http://www.aspose.com/docs/display/wordsnet/Considerations+When+Running+on+a+Shared+Server+Environment

解决方法也可以指定文件夹的路径,其中包含所有必需的字体。有关示例代码,请参阅http://www.aspose.com/docs/display/wordsnet/How+to++Specify+True+Type+Fonts+Location

我与 Aspose 合作,担任开发人员传道者。

于 2015-03-09T09:30:43.573 回答