小明跑到一家書店,問老闆說,你們這有沒有最可怕的故事書。老闆推推眼鏡,然後冷冷的回答說,有。於是從書架上取下一本書,並告訴小明,這本故事書很特別,每個章節都很恐怖,要價 1000元,你要買嗎?
小明沒有猶豫很久,就跟老闆說,我要買。當老闆把書交給小明之際,低聲的對小明說,有一件事你一定要特別注意,就是「千萬不要翻到最後一頁,千萬要記住喔」。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<style>
.input-group-addon {
/*設定每個 input-group-addon 都有固定寬度 */
min-width:180px;
}
.input-group{
padding-bottom:2px;
}
/*自動根據內容調整高度,同時設定最小高度*/
.input-group-btn, .input-group .form-control
{
height: auto;
min-height: 30px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<div>
</div>
<div class="row">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">學生姓名</span>
<asp:Label id="lb_學生姓名" runat="server" CssClass="form-control" Text="張小明" ></asp:Label>
</div>
</div>
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">年級班級</span>
<asp:Label id="lb_班級" runat="server" CssClass="form-control" Text="五年一班" ></asp:Label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">備註一</span>
<asp:Label id="lb_備註一" runat="server" CssClass="form-control" Text="" ></asp:Label>
</div>
</div>
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">備註二</span>
<asp:Label id="lb_備註二" runat="server" CssClass="form-control" Text="2014年校慶運動會跑步第一名<br>2015年校慶運動會跑步第二名<br>2016年全國運動會跑步第一名" ></asp:Label>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
{
"title":"jquery 入門",
"price":"299",
"author":"paladin lee"
}
public void ProcessRequest (HttpContext context) {
StringBuilder sb = new StringBuilder();
sb.Append(@"{
""title"":""jquery 入門"",
""price"":""299"",
""author"":""paladin lee""
}
");
//將 sb 物件序列化成JSON格式再回傳
context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(sb.ToString()));
}
$.each(data2, function (property, value) {
//Do something...
});
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
.tb
{
border-collapse:collapse ;
}
.tb th
{
border:1px solid black;
padding:5px;
}
.tb td
{
border:1px solid black;
padding:5px;
}
</style>
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script>
$(function () {
$.getJSON("ser01.ashx", function (data) {
var vTable = $("<table class='tb' border='1'></table>");
var vItem01="";
//convert JSON string, not an object
var data2 = $.parseJSON(data);
$.each(data2, function (property, value) {
vItem01 = vItem01 + "<tr><th>" + property + "</th><td>" + value + "</td></tr>";
});
$(vTable).append(vItem01);
$(".div01").append(vTable);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="div01">
</div>
</form>
</body>
</html>
[
{
"title":"jquery 入門",
"price":"299",
"author":"paladin lee"
},
{
"title":"html5 入門",
"price":"199",
"author":"Nikki"
},
{
"title":"麻將",
"price"":"99",
"author"":"jason"
}
]
public void ProcessRequest (HttpContext context) {
StringBuilder sb = new StringBuilder();
sb.Append(@"[
{
""title"":""jquery 入門"",
""price"":""299"",
""author"":""paladin lee""
},
{
""title"":""html5 入門"",
""price"":""199"",
""author"":""Nikki""
},
{
""title"":""麻將"",
""price"":""99"",
""author"":""jason""
}
]
");
//將 sb 物件序列化成JSON格式再回傳
context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(sb.ToString()));
}
$.each(data, function () {
//處理每一筆的資料
$.each(this,function(property, value){
//處理每一個欄位的資料
});
});
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
.tb
{
border-collapse:collapse ;
}
.tb th
{
border:1px solid black;
padding:5px;
}
.tb td
{
border:1px solid black;
padding:5px;
}
</style>
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script>
$(function () {
// test ser01
$.getJSON("server02.ashx", function (data) {
var vTable = $("<table class='tb' border='1'></table>");
var vItem01 = "";
//convert JSON string, not an object
var data2 = $.parseJSON(data);
//header
vItem01 += "<tr><th>title</th><th>price</th><th>author</th></tr>";
$.each(data2, function () {
vItem01+="<tr>";
$.each(this,function(property, value){
vItem01+="<td>"+value+"</td>";
});
vItem01 += "</tr>";
});
$(vTable).append(vItem01);
$(".div01").append(vTable);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="div01">
</div>
</form>
</body>
</html>
![]() |
| BackGround.png |
Document pdfDocument = new Document("PDF來源");
Page pdfPage = pdfDocument.Pages[1];
ImageStamp imgStamp = new ImageStamp(strStampFullPath);
class PdfFunction
{
public void AddBackGroundIMG(string PDFPath)
{
string setupFile = "BackGround.png";
//取得執行路徑
string strExecPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//取得檔案的完整路徑
string strStampFullPath = string.Format("{0}\\{1}", strExecPath, setupFile);
//設定 license
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(string.Format("{0}\\{1}",strExecPath , "Aspose.Total.lic"));
//透過 Aspose 的 Document 物件,來取得原先的 PDF 檔案
Document pdfDocument = new Document(PDFPath);
Page pdfPage;
for (int i = 0; i < pdfDocument.Pages.Count; i++)
{
//Aspose 是從 1 開始算的
pdfPage = pdfDocument.Pages[i + 1];
//取得外部圖片並指定為 ImageStamp 格式
ImageStamp imgStamp = new ImageStamp(strStampFullPath);
//將加入的圖片指定設為背景
imgStamp.Background = true;
//設定圖片長寬
imgStamp.Width = 850;
imgStamp.Height = 600;
//將底圖加入到 PDF 頁面
pdfPage.AddStamp(imgStamp);
}
// 產出新檔案
pdfDocument.Save(string.Format("{0}\\{1}", strExecPath, "out.pdf"));
}
}
class Program
{
static void Main(string[] args)
{
string setupFile = "award.pdf";
//取得執行路徑
string strExecPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//取得檔案的完整路徑
string strStampFullPath = string.Format("{0}\\{1}", strExecPath, setupFile);
PdfFunction oP = new PdfFunction();
oP.AddBackGroundIMG(setupFile);
}
}