コード例 #1
0
	    /// <summary>
		/// Creates a table cell
		/// </summary>
		public iTextSharp.text.pdf.PdfPCell CreateTableCell(XmlAttributeCollection cellAttrs, System.Collections.IDictionary data)
		{
			int colspan = Moon.PDFDraw.Helper.GetIntAttributeValue("colspan", cellAttrs, 0);
			int horizontalalign = PDFDrawItextSharpHelper.Align(
				Moon.PDFDraw.Helper.GetAttributeValue("horizontalalign", cellAttrs, "Left"));
			int border = PDFDrawItextSharpHelper.Border(
				Moon.PDFDraw.Helper.GetStringArray(BorderAttributeConstant, cellAttrs));
			iTextSharp.text.BaseColor borderColor = new iTextSharp.text.BaseColor(
				Moon.PDFDraw.Helper.GetAttributeColor("bordercolor", cellAttrs, "Black"));
			
			#if DEBUG
			//Console.WriteLine("PDFDrawItextSharp.CreateTableCell Border: " + border);
			#endif

			iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
			//iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell(new iTextSharp.text.Phrase("xx"));
			if (colspan > 1)
			{
				cell.Colspan = colspan;
			}
			
			float borderWidth = Moon.PDFDraw.Helper.GetFloatAttributeValue("borderwidth", cellAttrs, -1);
			float borderWidthLeft = Moon.PDFDraw.Helper.GetFloatAttributeValue("borderwidthleft", cellAttrs, -1);
			float borderWidthTop = Moon.PDFDraw.Helper.GetFloatAttributeValue("borderwidthtop", cellAttrs, -1);
			float borderWidthRight = Moon.PDFDraw.Helper.GetFloatAttributeValue("borderwidthright", cellAttrs, -1);
			float borderWidthBottom = Moon.PDFDraw.Helper.GetFloatAttributeValue("borderwidthbottom", cellAttrs, -1);
			if (borderWidth != -1) cell.BorderWidth = borderWidth;
			if (borderWidthLeft != -1) cell.BorderWidthLeft = borderWidthLeft;
			if (borderWidthTop != -1) cell.BorderWidthTop = borderWidthTop;
			if (borderWidthRight != -1) cell.BorderWidthRight = borderWidthRight;
			if (borderWidthBottom != -1) cell.BorderWidthBottom = borderWidthBottom;

			cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
			cell.EnableBorderSide(border);
			cell.HorizontalAlignment = horizontalalign;
			
			//cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_TOP;
			cell.BorderColor = borderColor;

			//20130610 :: Add background color
			if( Moon.PDFDraw.Helper.GetAttributeValue(BackgroundColorAttributeConstant, cellAttrs, null) != null ){
				cell.BackgroundColor = new BaseColor(Helper.GetAttributeColor(BackgroundColorAttributeConstant, cellAttrs, "White", data));
			}
			//---
			
			cell.UseAscender = true;
			cell.UseDescender = false;

			return cell;
		}
コード例 #2
0
		/// <summary>
		/// Creates a table cell
		/// </summary>
		/// <param name="colspan"></param>
		/// <param name="enableBroder_RECTANGLE_BORDER">iTextSharp.text.Rectangle.BOTTOM_BORDER
		///        | iTextSharp.text.Rectangle.RIGHT_BORDER
		///        | iTextSharp.text.Rectangle.LEFT_BORDER
		///        | iTextSharp.text.Rectangle.TOP_BORDER</param>
		/// <param name="horizontal_ELEMENT_ALIGN"></param>
		/// <param name="borderColor"></param>
		/// <param name="text"></param>
		/// <param name="font"></param>
		/// <returns></returns>
		public iTextSharp.text.pdf.PdfPCell CreateTableCell(
			int colspan,
			int enableBroder_RECTANGLE_BORDER,
			int horizontal_ELEMENT_ALIGN,
			iTextSharp.text.BaseColor borderColor,
			string text,
			iTextSharp.text.Font font)
		{
			iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
			if (colspan > 1)
			{
				cell.Colspan = colspan;
			}
			cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
			cell.EnableBorderSide(enableBroder_RECTANGLE_BORDER);
			cell.HorizontalAlignment = horizontal_ELEMENT_ALIGN;
			cell.BorderColor = borderColor;
			cell.Phrase = new iTextSharp.text.Phrase(text, font);
			cell.UseAscender = true;
			cell.UseDescender = false;

			return cell;
		}