惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Engineering at Meta
Engineering at Meta
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
N
News and Events Feed by Topic
Cloudbric
Cloudbric
B
Blog
Cisco Talos Blog
Cisco Talos Blog
V
Vulnerabilities – Threatpost
N
News and Events Feed by Topic
V
Visual Studio Blog
A
Arctic Wolf
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42
S
Security @ Cisco Blogs
博客园 - 聂微东
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
G
GRAHAM CLULEY
L
LINUX DO - 热门话题
量子位
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tenable Blog
月光博客
月光博客
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
D
Docker
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Help Net Security
Help Net Security
D
DataBreaches.Net

博客园 - Hawk_Yuan

JQGrid自動翻頁 aspose.cell C#通过SQL读写文件 Aspose.Cells asp.net mvc 4 json大数据异常 提示JSON字符长度超出限制的异常[转载] 日期转换成字符串 LinkServer GridView小记 SoapHeader Credential 等等等 决心要创业成功的10个必备信念 成功人的共性 会计科目 [转]BOM分层六项原则 [转]ERP核心理念讲座系列(四) [转]ERP核心理念讲座系列(三) [转]ERP核心理念讲座系列(二) [转]ERP核心理念讲座系列(一)
Aspose.Words
Hawk_Yuan · 2022-02-27 · via 博客园 - Hawk_Yuan


if (FormFields["COM_FORMNO"].Length > 0)
{
DataTable dt = new DataTable();
using (WF_SampleV5Service service = new WF_SampleV5Service(WFConn))
dt = service.GetReport(FormFields["COM_FORMNO"]);
try
{
oPage = (Page)oContainer;
//有用,关于 认证 暂不可删除
String AsposeLicPath = String.Empty;
if (System.Configuration.ConfigurationManager.AppSettings["DocLicPath"] == null)
throw new Exception("Please setup [AsposeLicPath] in Web.Config!");
else
AsposeLicPath = System.Configuration.ConfigurationManager.AppSettings["DocLicPath"];

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense(AsposeLicPath);

Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder db = new Aspose.Words.DocumentBuilder(doc);
for (int i = 0; i < dt.Rows.Count; i++)
{
db.PageSetup.HeaderDistance = 0;
db.PageSetup.FooterDistance = 0;
db.PageSetup.PageWidth = Convert.ToInt32(ConfigurationManager.AppSettings["PageWidth"].ToString());
db.PageSetup.PageHeight = Convert.ToInt32(ConfigurationManager.AppSettings["PageHeight"].ToString());
db.PageSetup.LeftMargin = 10;
db.PageSetup.TopMargin = 5;
db.PageSetup.RightMargin = 5;
db.PageSetup.BottomMargin = 5;
db.PageSetup.VerticalAlignment = Aspose.Words.PageVerticalAlignment.Center;

db.StartTable();
db.InsertCell();
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["TableWidth"].ToString());
db.Write("LITEON");
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
db.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
db.Font.Size = 14;
db.Font.Bold = true;
db.EndRow();

db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight2"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth1"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
db.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
db.Write("品名規格");
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight2"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth4"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top;
db.Write(dt.Rows[i]["Standard"].ToString());
db.EndRow();

db.InsertCell();
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth1"].ToString());
db.Font.Size = 12;
db.Font.Bold = false;
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
db.Write("料號");
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth2"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write(dt.Rows[i]["MaterialNO"].ToString());
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth3"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write("口CE:");
db.EndRow();

db.InsertCell();
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth1"].ToString());
db.Font.Size = 12;
db.Font.Bold = false;
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
db.Write("日期");
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth2"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write(dt.Rows[i]["IssueDate"].ToString());
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth3"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write("口EE:");
db.EndRow();

db.InsertCell();
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth1"].ToString());
db.Font.Size = 12;
db.Font.Bold = false;
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
db.Write("廠商");
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth2"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write(dt.Rows[i]["Supplier"].ToString());
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth3"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write("口ME:");
db.EndRow();

db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth1"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
db.Write("編號");
db.InsertCell();
db.Font.Size = 12;
db.Font.Bold = false;
db.RowFormat.Height = Convert.ToInt32(ConfigurationManager.AppSettings["RowHeight1"].ToString());
db.CellFormat.Width = Convert.ToInt32(ConfigurationManager.AppSettings["ColWidth4"].ToString());
db.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
db.Write(dt.Rows[i]["AcceptNO"].ToString());
db.EndRow();
db.EndTable();
}

Aspose.Words.Saving.PdfSaveOptions pdfSO = new Aspose.Words.Saving.PdfSaveOptions();
pdfSO.ZoomBehavior = Aspose.Words.Saving.PdfZoomBehavior.ZoomFactor;
//doc.Save(oPage.Response, HttpUtility.UrlEncode("(SampleFormUIShadow)UIShadow.pdf"), Aspose.Words.ContentDisposition.Attachment, pdfSO);
oPage.EnableViewState = false;
MemoryStream pdfdata = new MemoryStream();
doc.Save(pdfdata, pdfSO);
oPage.Response.Clear();
oPage.Response.ClearContent();
oPage.Response.ClearHeaders();
oPage.Response.ContentType = "application/pdf";
oPage.Response.Charset = string.Empty;
oPage.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
oPage.Response.AddHeader("Content-Disposition", "inline; filename=SampleIssue.pdf");

oPage.Response.OutputStream.Write(pdfdata.GetBuffer(), 0, pdfdata.GetBuffer().Length);
oPage.Response.OutputStream.Flush();
oPage.Response.OutputStream.Close();

oPage.Response.Flush();
oPage.Response.Close();
}
catch (Exception ex)
{
//写 将因为模板 版本过高造成的错误写入log,便于 IT 同仁查错
if (ex.Message.Contains("document appears to be corrupted and cannot be loaded."))
{
}
else
{
}

throw ex;
}
}