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

标签 c# asp.net ms-word spire.doc

在我的代码中,我正在使用 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/

相关文章:

c# - 在c#中转换xml文件中的excel文件

c# - 如何在使用 XmlConfigurator 加载后以编程方式设置 log4net LockingModel?

c# - 存储/获取信息客户端的最佳方式

asp.net - 从 Page 对象获取 PageName.aspx

javascript - 如何使用javascript自动关闭网页?

javascript - 如何在 MS Word 2013 中使用 String.replace() 方法而不弄乱空白段落和对象标识符?

c# - 如何在不将类标记为可序列化的情况下对其进行深度复制

c# - .net开发代码结构-Controllers, Services, Repositories & Contexts

excel - VBA TypeText Word Wrapping 内联与前一行的缩进

c# - 使用C#将特定页面从一个word文档复制到另一个word文档