static void Main(string[] args) { try { var strParams = new Dictionary<string, string>(); string base64 = string.Empty; var userName = ConfigurationManager.AppSettings["UserName"]; PDFSourceBaseGenerator instance = new PDFSourceBaseGenerator(); var pdfgen = new GeneratePDF(); //var pdfData = instance.getDBPDFInfo(38, userName, "TME-20180627"); //if (pdfData != null && pdfData.Rows.Count > 0) { Console.WriteLine("获取数据没问题"); var path = $"{AppDomain.CurrentDomain.BaseDirectory}协议书-TME.docx"; //pdfContent var pdfSourceContent = File.ReadAllBytes(path); //用户默认地址PostalAddress //strParams.Add("${PostalAddress}", pdfData.Rows[0][1] == null ? "" : pdfData.Rows[0][1].ToString()); // var PDFContent = instance.getPDFContent(38, strParams, pdfSourceContent, base64); var PDFContent = pdfgen.RequestPDF(pdfSourceContent, strParams, 1); if (PDFContent != null) { File.WriteAllBytes($"{AppDomain.CurrentDomain.BaseDirectory}aaaaaa.doc", PDFContent); Console.WriteLine("调用getPDFContent成功"); } else { Console.WriteLine("调用getPDFContent失败"); } PDFContent = pdfgen.RequestPDF(pdfSourceContent, strParams, 0); if (PDFContent != null) { File.WriteAllBytes($"{AppDomain.CurrentDomain.BaseDirectory}aaaaaa.pdf", PDFContent); Console.WriteLine("调用getPDFContent成功"); } else { Console.WriteLine("调用getPDFContent失败"); } } } catch (Exception er) { Console.WriteLine("异常了,exception=" + er.ToString()); } Console.ReadLine(); }