本文整理匯總了C#中iTextSharp.text.pdf.PdfPCell.DisableBorderSide方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfPCell.DisableBorderSide方法的具體用法?C# PdfPCell.DisableBorderSide怎麽用?C# PdfPCell.DisableBorderSide使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfPCell
的用法示例。
在下文中一共展示了PdfPCell.DisableBorderSide方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExportDataTableToPDF
/// <summary>
/// 導出DataTable數據到PDF
/// </summary>
/// <param name="dtSource">表名</param>
/// <param name="isColumnName">是否顯示列名</param>
/// <param name="FileName">文件完整路徑</param>
/// <param name="arrColWidth">列寬比例數組,數組長度必須等於DataTable列數;</param>
/// <param name="pdftable">公共模塊</param>
/// <param name="pdffooter">落款</param>
/// <param name="title">標題</param>
/// <param name="header">頁眉</param>
/// <param name="rows">表頭分rows列顯示</param>
/// <param name="count">每頁最多顯示count組記錄</param>
public void ExportDataTableToPDF(DataTable dtSource, bool isColumnName, string FileName, float[] arrColWidth, PdfPTable pdftable,PdfPTable pdffooter, string title, string header, int cols, uint count)
{
try
{
//創建實例
document = new Document(PageSize.A4.Rotate());
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(FileName, FileMode.Create));
OpenDocument();
//設置title和頁眉
writer.PageEvent = new HeaderAndFooterEvent();
HeaderAndFooterEvent.basefont = basefont;
HeaderAndFooterEvent.header = header;
HeaderAndFooterEvent.isPdfTable = true;
HeaderAndFooterEvent.pdftable = pdftable;
HeaderAndFooterEvent.PAGE_NUMBER = true;
HeaderAndFooterEvent.tpl = writer.DirectContent.CreateTemplate(100, 100);
if (!string.IsNullOrEmpty(title))
{
document.Add(HeaderAndFooterEvent.InsertTitleContent(title));
}
//添加table
int rows = (int)(dtSource.Columns.Count / cols);
if (dtSource.Columns.Count % cols != 0)
{
rows = rows + 1;
}
PdfPTable table = new PdfPTable(cols);
table.WidthPercentage = 100;
//沒有傳遞列寬比例時,獲取默認列表比較
float[] newArrColWidth = new float[dtSource.Columns.Count];
for (int i = 0; i < dtSource.Columns.Count; i++)
{
if (arrColWidth.Length > i)
{
newArrColWidth[i] = arrColWidth[i];
}
else
{
newArrColWidth[i] = newArrColWidth[i - cols];
}
}
table.SetWidths(arrColWidth);
//列名代表表頭
#region 是否顯示列名
if (isColumnName)
{
for (int i = 0; i < dtSource.Columns.Count; i++)
{
PdfPCell cell = new PdfPCell(new Phrase(dtSource.Columns[i].ColumnName, new Font(basefont, defaultFontSize, Font.BOLD)));
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
if (i / cols % rows == 0)
{
cell.DisableBorderSide(2); //1,2,4,8 分別對應每行的上,下,左,右四個邊框.
}
else if (i / cols % (rows - 1) == 0)
{
cell.DisableBorderSide(1);
}
else
{
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
}
table.AddCell(cell);
}
for (int j = dtSource.Columns.Count; j < cols * rows; j++)
{
PdfPCell cell = new PdfPCell(new Phrase("", new Font(basefont, defaultFontSize)));
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
if (rows == 1)
{
}
else if (j / cols % rows == 0)
{
cell.DisableBorderSide(2); //1,2,4,8 分別對應每行的上,下,左,右四個邊框.
}
else if (j / cols % (rows - 1) == 0)
{
cell.DisableBorderSide(1);
}
else
{
//.........這裏部分代碼省略.........
示例2: GetCarWaybillsPDF
//.........這裏部分代碼省略.........
Chunk c2 = new Chunk(CommonFunction.ZipAddress(dr["delivery_zip"].ToString()) + "\n\n" + dr["delivery_address"].ToString() + "\n\n\n", font);
font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
Chunk c3 = new Chunk(dr["delivery_mobile"].ToString(), font);
Phrase pinfor = new Phrase();
pinfor.Add(c1);
pinfor.Add(c2);
pinfor.Add(c3);
BarCode.Code128 _Code = new BarCode.Code128();
_Code.ValueFont = new System.Drawing.Font("宋體", 20);
System.Drawing.Bitmap imgTemp = _Code.GetCodeImage(order_id, BarCode.Code128.Encode.Code128A);
imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif"));
IMG.ScaleToFit(200, 40);
Chunk orderidck = new Chunk(IMG, 0, 0); //圖片可設置 偏移
imgTemp = _Code.GetCodeImage("D" + dr["deliver_id"].ToString().PadLeft(8, '0'), BarCode.Code128.Encode.Code128A);
imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif);
IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif"));
IMG.ScaleToFit(200, 40);
Chunk deliveridck = new Chunk(IMG, 0, 0); //圖片可設置 偏移
//PdfContentByte cb = writer.DirectContent;
// cb.BeginText();
if (i % 2 == 0 && i != 0)
{
document.NewPage();
}
PdfPTable totaltable = new PdfPTable(3);
totaltable.WidthPercentage = 100;
totaltable.SetWidths(new int[] { 45, 2, 53 });
totaltable.DefaultCell.DisableBorderSide(1);
totaltable.DefaultCell.DisableBorderSide(2);
totaltable.DefaultCell.DisableBorderSide(4);
totaltable.DefaultCell.DisableBorderSide(8);
PdfPCell cell;
#region 左邊框
PdfPTable table = new PdfPTable(4);
table.SetTotalWidth(new float[] { 60, 75, 10, 100 });
table.DefaultCell.UseAscender = true;
table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell = new PdfPCell(new Phrase("出貨日", font));
cell.FixedHeight = 17f;
table.AddCell(cell);
table.AddCell(new Phrase("預定配送日", font));
cell = new PdfPCell(new Phrase("指定時段", font));
cell.Colspan = 2;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(DateTime.Now.ToString("yyyyMMdd"), font));
cell.FixedHeight = 17f;
table.AddCell(cell);
//table.AddCell(new Phrase(DateTime.Now.ToString("yyyyMMdd"), font));
table.AddCell(new Phrase(estimated_delivery_date, font));
table.AddCell(new Phrase(estimated_arrival_period, font));
table.AddCell(new Phrase(sestimated_arrival_period, font));
table.AddCell(new Phrase("收\n件\n人", font));
cell = new PdfPCell(pinfor);
cell.Colspan = 3;
table.AddCell(cell);
table.AddCell(new Phrase("寄件人", font));
font = new iTextSharp.text.Font(bfChinese, 7, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
cell = new PdfPCell(new Phrase("台北市南港區八德路四段768巷5號4F之一 \n\n 吉甲地好市集股份有限公司", font));
示例3: GetDeliverDetailsPDF
//.........這裏部分代碼省略.........
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("數量", font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("售價", font));
ptable.AddCell(cell);
PdfPCell td = new PdfPCell();
td.BorderWidth = 0.1f;
int j = 0;
foreach (var item in deliverdetails)
{
j++;
for (int i = 0; i < item.Count(); i++)
{
string item_id = string.Empty;
if (item[i]["item_mode"].ToString() == "1")
{
item_id = item[i]["parent_id"].ToString();
}
else
{
item_id = item[i]["item_id"].ToString();
}
cell = new PdfPCell(new Phrase(item_id, font));
ptable.AddCell(cell);
string datacontent = ((item[i]["item_mode"].ToString() == "2") ? " *" : "") + item[i]["product_name"].ToString() + item[i]["product_spec_name"].ToString();
cell = new PdfPCell(new Phrase(item[i]["brand_name"].ToString() + "-" + datacontent, font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(item[i]["buy_num"].ToString(), font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(item[i]["item_mode"].ToString() == "1" ? "" : item[i]["single_money"].ToString(), font));
ptable.AddCell(cell);
}
if (deliverdetails.Count > 1 && j != deliverdetails.Count)
{
td = new PdfPCell();
td.Colspan = 4;
td.BorderWidthTop = 0.2f;
td.DisableBorderSide(2);
ptable.AddCell(td);
}
}
ptable.WriteSelectedRows(0, -1, 10, 620, writer.DirectContent);
}
else
{
PdfPTable ptable = new PdfPTable(4);
// ptable.WidthPercentage = 90;
// ptable.TotalWidth = ptable.WidthPercentage;
ptable.SetTotalWidth(new float[] { 100, 350, 70, 70 });
PdfPCell cell = new PdfPCell();
cell.BorderWidth = 0.1f;
cell = new PdfPCell(new Phrase("產品細項編號", font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("產品名稱", font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("規格", font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("數量", font));
ptable.AddCell(cell);
int j = 0;
foreach (var item in deliverdetails)
{
j++;
for (int i = 0; i < item.Count(); i++)
{
cell = new PdfPCell(new Phrase(item[i]["item_id"].ToString(), font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(item[i]["brand_name"].ToString() + "-" + item[i]["product_name"].ToString(), font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(item[i]["product_spec_name"].ToString(), font));
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(item[i]["buy_num"].ToString(), font));
ptable.AddCell(cell);
}
if (deliverdetails.Count > 1 && j != deliverdetails.Count)
{
cell = new PdfPCell();
cell.Colspan = 4;
cell.BorderWidthTop = 0.2f;
cell.DisableBorderSide(2);
ptable.AddCell(cell);
}
}
ptable.WriteSelectedRows(0, -1, 10, 620, writer.DirectContent);
}
cb.EndText();
document.Close();
writer.Resume();
Response.Clear();
Response.Charset = "gb2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// Response.AddHeader("Content-Disposition", "attach-ment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".pdf ");
Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename);
Response.WriteFile(newPDFName);
}
}
示例4: GetShopbillsPDF
//.........這裏部分代碼省略.........
}
break;
case "L":
if (stnm.Length * 3 >= 10)
{
stnm_1 = stnm.Substring(0, 10 / 3);
}
else
{
stnm_1 = stnm.Substring(0, stnm.Length);
}
if (stnm.Length * 3 >= 40)
{
stnm_2 = stnm.Substring(9 / 3, 40 / 3);
}
else
{
if (stnm.Length * 3 >= 9)
{
stnm_2 = stnm.Substring(9 / 3, stnm.Length - 9 / 3);
}
}
break;
default:
break;
}
}
PdfPTable totaltable = new PdfPTable(3);
totaltable.WidthPercentage = 100;
totaltable.SetWidths(new int[] { 40, 2, 58 });
PdfPTable table = new PdfPTable(3);
#region 左邊框
table.SetWidths(new int[] { 25, 15, 60 });
table.DefaultCell.DisableBorderSide(1);
table.DefaultCell.DisableBorderSide(2);
table.DefaultCell.DisableBorderSide(4);
table.DefaultCell.DisableBorderSide(8);
PdfPCell cell;
font = new iTextSharp.text.Font(bf, 14, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑
cell = new PdfPCell(new PdfPCell(new Phrase(dr["dcrono"].ToString(), font)));
cell.UseAscender = true;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(" 提貨人:" + dr["delivery_name"].ToString(), font));
cell.Colspan = 2;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
table.AddCell(cell);
cell = new PdfPCell(new Phrase(stnm_1 + "\n" + stnm_2, font));
cell.Colspan = 2;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
table.AddCell(cell);
cell = new PdfPCell(new Phrase(ck1));
cell.UseAscender = true;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
示例5: GetOrderDetailsPDF
//.........這裏部分代碼省略.........
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_id"].ToString(), 65, 660, 0);
address += CommonFunction.ZipAddress(orderdeliver.Rows[0]["delivery_zip"].ToString()) + orderdeliver.Rows[0]["delivery_address"].ToString();
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, address, 250, 660, 0);
string order_createdate = orderdeliver.Rows[0]["order_createdate"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["order_createdate"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "";
string money_collect_date = orderdeliver.Rows[0]["money_collect_date"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["money_collect_date"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "";
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, order_createdate, 65, 640, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["delivery_mobile"].ToString(), 250, 640, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, money_collect_date, 65, 620, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["holiday_deliver"].ToString() == "1" ? "可" : "不可", 260, 620, 0);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["note_order"].ToString().Trim(), 65, 600, 0);
if (orderdeliver.Rows[0]["delivery_store"].ToString() == "12")
{
deliver_note = "*自取(取貨地址:台北市南港區八德路4段768巷7號6樓之1,取貨時間週一~週五,AM9:00~PM6:00)";
}
else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "13")
{
deliver_note = "*自取(取貨地址:新北市板橋區三民路二段33號21樓,取貨時間週一~週五,AM9:00~PM6:00)";
}
else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "14")
{
deliver_note = "*自取(取貨地址:新北市永和區成功路一段80號20樓,取貨時間週一~週五,AM9:00~PM6:00)";
}
cb.SetFontAndSize(bfChinese, 8);
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliver_note, 65, 580, 0);
}
cb.EndText();
PdfPTable ptable = new PdfPTable(7);
ptable.WidthPercentage = 98;
ptable.SetTotalWidth(new float[] { 50, 280, 50, 50, 50, 50, 50 });
PdfPCell cell;
font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
cell = new PdfPCell(new Phrase("商品編號", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("商品名稱", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("托運單屬性", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("數量", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("本次出貨", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("預計出貨日", font));
cell.DisableBorderSide(2);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("供應商自出", font));
cell.DisableBorderSide(2);
ptable.AddCell(cell);
PdfPCell td;
string lastdeliverid = "0";
ArrayList normal = new ArrayList();
ArrayList low = new ArrayList();
ArrayList lowstore = new ArrayList();
DataRow[] sinceorder = new DataRow[] { };
示例6: KTPrintPDF
public void KTPrintPDF()
{
PdfHelper pdf = new PdfHelper();
List<string> pdfList = new List<string>();
float[] arrColWidth = new float[] { 60, 60, 100, 60, 50, 30, 60, 60, 60, 60 };
int index = 0;
string newFileName = string.Empty;
string newName = string.Empty;
string json = string.Empty;
IialgQuery q = new IialgQuery();
if (!string.IsNullOrEmpty(Request.Params["KT_NO"].Trim().ToUpper()))//by zhaozhi0623j add 20151006
{
q.doc_no = Request.Params["KT_NO"].Trim().ToUpper();
}
try
{
List<IialgQuery> store = new List<IialgQuery>();
_iagMgr = new IialgMgr(mySqlConnectionString);
int totalCount = 0;
q.IsPage = false;
store = _iagMgr.GetIialgList(q, out totalCount);
int rid = 0;
DataTable _dtBody = new DataTable();
if (store.Count > 0)
{
_dtBody.Columns.Add("商品細項編號", typeof(string));
_dtBody.Columns.Add("主料位", typeof(string));
_dtBody.Columns.Add("商品名稱", typeof(string));
_dtBody.Columns.Add("規格", typeof(string));
_dtBody.Columns.Add("調整原因", typeof(string));
_dtBody.Columns.Add("數量", typeof(string));
_dtBody.Columns.Add("調整料位", typeof(string));
_dtBody.Columns.Add("有效日期", typeof(string));
_dtBody.Columns.Add("前置單號", typeof(string));
_dtBody.Columns.Add("備註", typeof(string));
for (int i = 0; i < store.Count; i++)
{
store[i].id = rid++;
store[i].qty = store[i].qty_o + store[i].adj_qty;
DataRow newRow = _dtBody.NewRow();
newRow["商品細項編號"] = store[i].item_id;
newRow["主料位"] = store[i].loc_id;
newRow["商品名稱"] = store[i].product_name;
newRow["規格"] = string.IsNullOrEmpty(store[i].prod_sz) ? " " : store[i].prod_sz;
newRow["調整原因"] = string.IsNullOrEmpty(store[i].iarc_id) ? " " : store[i].iarc_id;
newRow["數量"] = store[i].adj_qty;
newRow["調整料位"] = store[i].loc_R;
newRow["有效日期"] = store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10) == "0001-01-01" ? " " : store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10);
newRow["前置單號"] = string.IsNullOrEmpty(store[i].po_id) ? " " : store[i].po_id;
newRow["備註"] = string.IsNullOrEmpty(store[i].remarks) ? " " : store[i].remarks;
_dtBody.Rows.Add(newRow);
}
}
string UsingName = " ";
String UsingTime = " ";
if (store.Count > 0)
{
UsingName = store[0].name;
UsingTime = store[0].create_dtim.ToString("yyyy/MM/dd");
}
BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑
string filename = "庫存調整" + DateTime.Now.ToString("yyyyMMddHHmmss");
Document document = new Document(PageSize.A4.Rotate());
string newPDFName = Server.MapPath(excelPath) + filename;
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
document.Open();
#region 庫存調整單頭
PdfPTable ptable = new PdfPTable(10);
ptable.WidthPercentage = 100;//表格寬度
ptable.SetTotalWidth(arrColWidth);
PdfPCell cell = new PdfPCell();
cell = new PdfPCell(new Phrase("執行人員:" + UsingName, new iTextSharp.text.Font(bf, 10)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 2;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10)));
cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
cell.Colspan = 8;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("執行日期:" + UsingTime, new iTextSharp.text.Font(bf, 10)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 2;
//.........這裏部分代碼省略.........
示例7: CountBookPDF
/// <summary>
/// 匯出盤點工作PDF
/// </summary>
public void CountBookPDF()
{
PdfHelper pdf = new PdfHelper();
List<string> pdfList = new List<string>();
float[] arrColWidth = new float[] { 25, 60, 40, 40, 55,40, 140, 50, 40, 50};
string newFileName = string.Empty;
string newName = string.Empty;
string json = string.Empty;
BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑
string filename = "盤點工作" + DateTime.Now.ToString("yyyyMMddHHmmss");
Document document = new Document(PageSize.A4.Rotate());
string newPDFName = Server.MapPath(excelPath) + filename;
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
document.Open();
int index = 0;
CbjobMasterQuery query = new CbjobMasterQuery();
List<CbjobMasterQuery> cbjobList = new List<CbjobMasterQuery>();
query.IsPage = false;
if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
{
query.row_id_IN = Request.Params["rowIDs"].TrimEnd(',');
}
_CbjobMasterMgr = new CbjobMasterMgr(mySqlConnectionString);
int totalCount = 0;
cbjobList = _CbjobMasterMgr.GetjobMaster(query, out totalCount);
DataTable _dtBody = new DataTable();
_dtBody.Columns.Add("編號", typeof(string));
_dtBody.Columns.Add("條碼", typeof(string));
_dtBody.Columns.Add("料位", typeof(string));
_dtBody.Columns.Add("現有庫存", typeof(string));
_dtBody.Columns.Add("盤點數量", typeof(string));
_dtBody.Columns.Add("效期控製", typeof(string));
_dtBody.Columns.Add("品名", typeof(string));
_dtBody.Columns.Add("規格", typeof(string));
_dtBody.Columns.Add("細項編號", typeof(string));
_dtBody.Columns.Add("備註", typeof(string));
PdfPTable ptablefoot = new PdfPTable(10);
if (cbjobList.Count > 0)
{
_cbjobMgr = new CbjobDetailMgr(mySqlConnectionString);
for (int i = 0; i < cbjobList.Count; i++)
{
CbjobDetail cbdetail = new CbjobDetail();
cbdetail.cb_jobid = cbjobList[i].cbjob_id;
DataTable _dtdetail = _cbjobMgr.GetDetailTable(cbdetail);
_dtBody.Rows.Clear();
#region 標頭
#region 標頭
PdfPTable ptable = new PdfPTable(10);
ptable.WidthPercentage = 100;//表格寬度
ptable.SetTotalWidth(arrColWidth);
PdfPCell cell = new PdfPCell();
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 10;
cell.DisableBorderSide(1);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 4;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
// cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(" 盤點薄" + "-" + cbdetail.cb_jobid, new iTextSharp.text.Font(bf, 18)));
cell.VerticalAlignment = Element.ALIGN_LEFT;
cell.Colspan = 3;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 3;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
// cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
//.........這裏部分代碼省略.........
示例8: AseldPDFS
public void AseldPDFS()
{
PdfHelper pdf = new PdfHelper();
List<string> pdfList = new List<string>();
float[] arrColWidth = new float[] { 135,50,45, 60, 55, 55,60, 45, 35, 45, 45, 35 };
int index = 0;
string newFileName = string.Empty;
string newName = string.Empty;
string json = string.Empty;
BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑
string filename = "總量撿貨報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
Document document = new Document(PageSize.A4.Rotate());
string newPDFName = Server.MapPath(excelPath) + filename;
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
document.Open();
string user_username = (Session["caller"] as Caller).user_username;
DataTable aseldTable = new DataTable();
DataTable assg_idTable = new DataTable();
AseldQuery ase_query = new AseldQuery();
ase_query.IsPage = false;
ase_query.assg_id = string.Empty;
ase_query.start_dtim = DateTime.MinValue;
ase_query.change_dtim = DateTime.MinValue;
int total = 0;
//PdfHelper pdf = new PdfHelper();
//List<string> pdfList = new List<string>();
//string newfilename = string.Empty;
//string filename = "待撿貨商品報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
//string newPDFName = Server.MapPath(excelPath) + filename;
//int index = 0;
int serchWhr = 0;
if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
{
ase_query.assg_id = Request.Params["assg_id"].Trim();
serchWhr++;
}
DateTime date = DateTime.MinValue;
if (Request.Params["start_time"] != "null" && Request.Params["end_time"] != "null")
{
if (DateTime.TryParse(Request.Params["start_time"], out date))
{
ase_query.start_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
}
if (DateTime.TryParse(Request.Params["end_time"], out date))
{
ase_query.change_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
}
serchWhr++;
}
IAseldImplMgr aseldMgr = new AseldMgr(mySqlConnectionString);
DataTable _dtBody = new DataTable();
_dtBody.Columns.Add("商品名稱", typeof(string));
_dtBody.Columns.Add("料位編號", typeof(string));
_dtBody.Columns.Add("撿貨庫存", typeof(string));
_dtBody.Columns.Add("本次撿貨量", typeof(string));
_dtBody.Columns.Add("製造日期", typeof(string));
_dtBody.Columns.Add("有效日期", typeof(string));
_dtBody.Columns.Add("條碼", typeof(string));
_dtBody.Columns.Add("細項編號", typeof(string));
_dtBody.Columns.Add("訂貨量", typeof(string));
_dtBody.Columns.Add("已撿貨量", typeof(string));
_dtBody.Columns.Add("待撿貨量", typeof(string));
_dtBody.Columns.Add("備註", typeof(string));
PdfPTable ptablefoot = new PdfPTable(14);
#region MyRegion
#region 數據行
if (ase_query.assg_id != string.Empty)
{
_dtBody.Rows.Clear();
aseldTable = aseldMgr.GetAseldTable(ase_query, out total);
#region 標頭
#region 表頭
PdfPTable ptable = new PdfPTable(12);
ptable.WidthPercentage = 100;//表格寬度
ptable.SetTotalWidth(arrColWidth);
PdfPCell cell = new PdfPCell();
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 12;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
//.........這裏部分代碼省略.........
示例9: WritePdf
//.........這裏部分代碼省略.........
{
List<IpodQuery> s = new List<IpodQuery>();
product_freight_set_mapping.Add(freiset, s);
}
product_freight_set_mapping[freiset].Add(ipodStore[i]);
}
#endregion
#region 針對匯出一個而無商品的pdf
if (ipodStore.Count == 0)
{
#region 獲取供應商信息
Vendor vendor = new Vendor();
_vendorMgr = new VendorMgr(mySqlConnectionString);
vendor.erp_id = ipoStore[a].vend_id;
vendor = _vendorMgr.GetSingle(vendor);
#endregion
#region 採購單標題
PdfPTable ptable = new PdfPTable(7);
ptable.WidthPercentage = 100;//表格寬度
font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑
ptable.SetTotalWidth(arrColWidth);
PdfPCell cell = new PdfPCell();
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 2;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase(" 吉甲地好市集股份有限公司", new iTextSharp.text.Font(bf, 15)));
cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
cell.Colspan = 5;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 3;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("採購單" + "-" + ipoStore[a].po_type_desc, new iTextSharp.text.Font(bf, 12)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 4;
cell.DisableBorderSide(1);
cell.DisableBorderSide(2);
cell.DisableBorderSide(4);
cell.DisableBorderSide(8);
ptable.AddCell(cell);
cell = new PdfPCell(new Phrase("公司電話:", new iTextSharp.text.Font(bf, 8)));
cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
cell.Colspan = 6;
cell.DisableBorderSide(1);