gpt4 book ai didi

c# - 古吉拉特语生成 PDF 时不支持托管 AWS 服务器 ASP.NET

转载 作者:行者123 更新时间:2023-12-05 03:48:17 27 4
gpt4 key购买 nike

在我的代码中,我正在使用 Spire.Doc 查找和替换 Word 文件中的一些特定单词,并使用 Microsoft.Office.Interop.Word 导出 PDF 文件打包它在本地服务器上对我来说工作正常但不能在 ASP.Net

中的 AWS 托管服务器上工作

[在本地工作]

enter image description here

[服务器图像有语法问题]

enter image description here

//doc creation
Spire.Doc.Document doc = new Spire.Doc.Document(Server.MapPath("~/Download/demo.docx"));
doc.Replace("todayDate", DateTime.Now.Date.ToString("dd-MM-yyyy"), true, true);
doc.Replace("App_Name", AppName, true, true);
doc.Replace("App_Date", App_Date, true, true);
doc.Replace("Sales_Name", SalesName, true, true);
doc.Replace("App_Address", App_Address, true, true);
doc.Replace("Sales_Address", Sales_Address, true, true);
doc.Replace("csNO", csNO, true, true);
doc.Replace("tnmntNO", TenamentNO, true, true);

doc.SaveToFile(string.Concat(Server.MapPath("~/hukam/"), App_id, ".docx"), FileFormat.Auto);

doc.Close();

//pdf genration
using Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;
Word._Application oword = new Word.Application();
oword.Visible = false;
object oMissing = System.Reflection.Missing.Value;
object isVisible = true;
object readOnly = false;
object oInput = string.Concat(Server.MapPath("~/hukam/"), App_id, ".docx");
string oOutput = string.Concat(Server.MapPath("~/hukam/"), App_id, ".pdf");

Word._Document oDoc = oword.Documents.Open(oInput,oMissing,readOnly,oMissing);
oDoc.Activate();
oDoc.EmbedTrueTypeFonts = true;
if (oDoc.Paragraphs.Count > 0)
{
foreach (Paragraph p in oDoc.Paragraphs)
{
p.Range.Font.Name = "Shruti";
}
}

if (oDoc.Footnotes.Count > 0)
{
foreach (Footnote fn in oDoc.Footnotes)
{
fn.Range.Font.Name = "Shruti";
}
}

oDoc.ExportAsFixedFormat(oOutput, WdExportFormat.wdExportFormatPDF);
oDoc.Close();
oword.Quit();

最佳答案


我试图通过更改一些代码来解决它,它对我来说效果很好。我在这里发布答案。可能对某人有帮助。

            Spire.Doc.Document doc = new Spire.Doc.Document(Server.MapPath("~/Download/demo.docx"));
doc.Replace("todayDate", DateTime.Now.Date.ToString("dd-MM-yyyy"), true, true);
doc.Replace("App_Name", AppName, true, true);
doc.Replace("App_Date", App_Date, true, true);
doc.Replace("Sales_Name", SalesName, true, true);
doc.Replace("App_Address", App_Address, true, true);
doc.Replace("Sales_Address", Sales_Address, true, true);
doc.Replace("csNO", csNO, true, true);
doc.Replace("tnmntNO", TenamentNO, true, true);
doc.Replace("txtNondh", txtNon, true, true);

doc.SaveToFile(string.Concat(Server.MapPath("~/hukam/"), App_ID, ".docx"), FileFormat.Auto);

doc.Close();

//creating PDF
RichEditDocumentServer wordProcessor = new RichEditDocumentServer();
wordProcessor.LoadDocument(string.Concat(Server.MapPath("~/hukam/"), App_ID, ".docx"), DocumentFormat.OpenXml);

//Specify export options:
PdfExportOptions options = new PdfExportOptions();
options.DocumentOptions.Author = "ArpitPatel";
options.Compressed = false;
options.ImageQuality = PdfJpegImageQuality.Highest;

//Export the document to the stream:
using (FileStream pdfFileStream = new FileStream(string.Concat(Server.MapPath("hukam/"), App_ID, ".pdf"), FileMode.Create))
{
wordProcessor.ExportToPdf(pdfFileStream, options);
}

感谢和问候

关于c# - 古吉拉特语生成 PDF 时不支持托管 AWS 服务器 ASP.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64510641/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com