当前位置: 首页>>代码示例>>C#>>正文


C# iTextSharp类代码示例

本文整理汇总了C#中iTextSharp的典型用法代码示例。如果您正苦于以下问题:C# iTextSharp类的具体用法?C# iTextSharp怎么用?C# iTextSharp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


iTextSharp类属于命名空间,在下文中一共展示了iTextSharp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTextContents

		/// <summary>
		/// Gets the text contents.
		/// </summary>
		/// <param name="textCollection">The text collection.</param>
		/// <returns>The content. ArrayList of chunks and phrases.</returns>
		public static ICollection GetTextContents(ITextCollection textCollection, iTextSharp.text.Font font)
		{
			ArrayList contents = new ArrayList();
			foreach(object obj in textCollection)
			{
				if (obj is AODL.Document.Content.Text.FormatedText)
				{
					contents.Add(FormatedTextConverter.Convert(
						obj as AODL.Document.Content.Text.FormatedText));
				}
				else if (obj is AODL.Document.Content.Text.SimpleText)
				{
					contents.Add(SimpleTextConverter.Convert(
						obj as AODL.Document.Content.Text.SimpleText, font));
				}
				else if (obj is AODL.Document.Content.Text.TextControl.TabStop)
				{
					contents.Add(SimpleTextConverter.ConvertTabs(
						obj as AODL.Document.Content.Text.TextControl.TabStop, font));
				}
				else if (obj is AODL.Document.Content.Text.TextControl.WhiteSpace)
				{
					contents.Add(SimpleTextConverter.ConvertWhiteSpaces(
						obj as AODL.Document.Content.Text.TextControl.WhiteSpace, font));
				}
			}
			return contents;
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:33,代码来源:FormatedTextConverter.cs

示例2: DrawBorder

		public void DrawBorder (iTextSharp.text.pdf.PdfContentByte contentByte,
		                        iTextSharp.text.Rectangle rectangle,
		                        ICSharpCode.Reports.Core.Exporter.IBaseStyleDecorator style)
		{
			if ( contentByte == null) {
				throw new ArgumentNullException("contentByte");
			}

			contentByte.SetColorStroke(style.PdfFrameColor);
			contentByte.SetLineWidth(UnitConverter.FromPixel(baseline.Thickness).Point);
			
			contentByte.MoveTo(rectangle.Left ,rectangle.Top );
			
			contentByte.LineTo(rectangle.Left, rectangle.Top - rectangle.Height);
			
			contentByte.LineTo(rectangle.Left + rectangle.Width, rectangle.Top - rectangle.Height);
			
			contentByte.LineTo(rectangle.Left   + rectangle.Width, rectangle.Top);
			
			contentByte.LineTo(rectangle.Left, rectangle.Top);
			
			contentByte.FillStroke();
			contentByte.ResetRGBColorFill();
			
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:25,代码来源:Border.cs

示例3: CreatePath

		//	http://www.mikesdotnetting.com/Article/88/iTextSharp-Drawing-shapes-and-Graphics
		
		public override void CreatePath(iTextSharp.text.pdf.PdfContentByte contentByte,
		                                BaseLine line,
		                                IBaseStyleDecorator style,
		                                iTextSharp.text.Rectangle rectangle)
		{
		
			if (contentByte == null) {
				throw new ArgumentNullException("contentByte");
			}
		
			if (style == null) {
				throw new ArgumentNullException("style");
			}
			if (rectangle == null) {
				throw new ArgumentNullException("rectangle");
			}
		
			if (line == null) {
				BaseShape.FillBackGround(contentByte,style,rectangle);
			} 
			else
			{
				BaseShape.SetupShape(contentByte,style);
				contentByte.SetLineWidth(UnitConverter.FromPixel(line.Thickness).Point);
				contentByte.RoundRectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height, CornerRadius);
				BaseShape.FinishShape(contentByte);
			}
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:30,代码来源:RectangleShape.cs

示例4: ScaleIfNessarry

		/// <summary>
		/// Scales the pdf image if nessarry by percent.
		/// </summary>
		/// <param name="img">The img.</param>
		/// <param name="frame">The frame.</param>
		/// <returns>The scaled image.</returns>
		private iTextSharp.text.Image ScaleIfNessarry(iTextSharp.text.Image img, Frame frame)
		{
			try
			{
				double scalingPrescision = 0.25;
				double scaledWidthPercent = 0;
				double scaledHeightPercent = 0;
				double odfScaledWidth = AODL.Document.Helper.SizeConverter.GetDoubleFromAnOfficeSizeValue(frame.SvgWidth);
				double odfScaledHeight = AODL.Document.Helper.SizeConverter.GetDoubleFromAnOfficeSizeValue(frame.SvgHeight);
				
				if ((frame.Height - odfScaledHeight) > scalingPrescision 
					|| (frame.Height - odfScaledHeight) < scalingPrescision)
				{
					scaledHeightPercent = ((100.0/frame.Height) * odfScaledHeight);
					Console.WriteLine("ScaledHeightPerc {0} , frame {1}, odfScaledHeight {2}", scaledHeightPercent, frame.Height, odfScaledHeight);
				}

				if ((frame.Width - odfScaledWidth) > scalingPrescision
					|| (frame.Width - odfScaledWidth) < scalingPrescision)
				{
					scaledWidthPercent = ((100.0/frame.Width) * odfScaledWidth);
				}
				
				if (scaledHeightPercent != 0 || scaledWidthPercent != 0)
				{
					img.ScalePercent((float) scaledWidthPercent, (float) scaledHeightPercent);
				}

				return img;
			}
			catch(Exception)
			{
				throw;
			}
		}
开发者ID:monsterlabs,项目名称:HumanRightsTracker,代码行数:41,代码来源:ImageConverter.cs

示例5: CreatePath

		public override void CreatePath(iTextSharp.text.pdf.PdfContentByte contentByte,
		                                BaseLine line,
		                                IBaseStyleDecorator style,
		                                Point from,Point to)
		{
			throw new NotImplementedException();
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:7,代码来源:EllipseShape.cs

示例6: RectangleJ

 public RectangleJ(iTextSharp.text.Rectangle rect) {
     rect.Normalize();
     x = rect.Left;
     y = rect.Bottom;
     width = rect.Width;
     height = rect.Height;
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: CreatePath

		public override void CreatePath(iTextSharp.text.pdf.PdfContentByte contentByte,
		                                BaseLine line,
		                                IBaseStyleDecorator style,
		                                iTextSharp.text.Rectangle rectangle)
		{
			if (contentByte == null) {
				throw new ArgumentNullException("contentByte");
			}
			if (style == null) {
				throw new ArgumentNullException("style");
			}
			if (rectangle == null) {
				throw new ArgumentNullException("rectangle");
			}
			
			if ((line == null)||(line.Thickness < 1)) {
				BaseShape.FillBackGround(contentByte,style,rectangle);
			}
			else if ((style.BackColor == GlobalValues.DefaultBackColor)) {
				BaseShape.SetupShape(contentByte,style);
				contentByte.SetLineWidth(UnitConverter.FromPixel(line.Thickness).Point);
				contentByte.MoveTo(rectangle.Left ,rectangle.Top );
				contentByte.LineTo(rectangle.Left, rectangle.Top - rectangle.Height);
				contentByte.LineTo(rectangle.Left + rectangle.Width, rectangle.Top - rectangle.Height);
				contentByte.LineTo(rectangle.Left   + rectangle.Width, rectangle.Top);
				contentByte.LineTo(rectangle.Left, rectangle.Top);
				BaseShape.FinishShape(contentByte);
			} else {
				BaseShape.FillBackGround(contentByte,style,rectangle);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:31,代码来源:RectangleShape.cs

示例8: OnStartPage

        public override void OnStartPage(PdfWriter writer, iTextSharp.text.Document document)
        {
            iTextSharp.text.Image header = iTextSharp.text.Image.GetInstance(PathResolver.MapPath("images/ADB_Logo.gif"));

            PdfPTable tableHeader = new PdfPTable(2);
            tableHeader.WidthPercentage = 100;

            PdfPCell imageHeaderCell = new PdfPCell(header);
            imageHeaderCell.Rowspan = 2;
            imageHeaderCell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
            imageHeaderCell.Border = 0;
            imageHeaderCell.PaddingBottom = 3;
            tableHeader.AddCell(imageHeaderCell);

            Font helvetica20 = FontFactory.GetFont(FontFactory.HELVETICA, 16);
            PdfPCell typeNameCell = new PdfPCell(new Phrase(TypesReader.GetDiagramName(this.type), helvetica20));
            typeNameCell.HorizontalAlignment = 2;
            typeNameCell.Border = 0;
            tableHeader.AddCell(typeNameCell);

            PdfPCell adbCell = new PdfPCell(new Phrase(GlobalStringResource.ADB, helvetica20));
            adbCell.HorizontalAlignment = 2;
            adbCell.Border = 0;
            tableHeader.AddCell(adbCell);

            PdfPCell lineCell = new PdfPCell();
            lineCell.Colspan = 2;
            lineCell.Border = 1;
            lineCell.PaddingBottom = 5;
            tableHeader.AddCell(lineCell);

            document.Add(tableHeader);
        }
开发者ID:meanprogrammer,项目名称:sawebreports_migrated,代码行数:33,代码来源:HeaderFooterHandler.cs

示例9: FillEvent

 public void FillEvent(float[] hdrTableLayout, string[] hdrNameList, int shid, string payeeName, string title, iTextSharp.text.Image imgLogo)
 {
     _hdrTableLayout = hdrTableLayout;
     _hdrNameList = hdrNameList;
     _payeeName = payeeName;
     _shid = shid.ToString();
     _title = title;
     _imgLogo = imgLogo;
 }
开发者ID:jwebb-vtg,项目名称:WSCIEMP,代码行数:9,代码来源:rptBeetPaymentBreakdown.cs

示例10: FillEvent

 public void FillEvent(string title, iTextSharp.text.Image imgLogo, int pageNumber, string shid, string businessName, string landownerName)
 {
     _title = title;
     _imgLogo = imgLogo;
     _shid = shid;
     _businessName = businessName;
     _landownerName = landownerName;
     _pageNumber = pageNumber;
 }
开发者ID:jwebb-vtg,项目名称:WSCIEMP,代码行数:9,代码来源:rptFieldSummary.cs

示例11: AddParagraph

 public static void AddParagraph(Document doc, int alignment, iTextSharp.text.Font font, iTextSharp.text.IElement content)
 {
     Paragraph paragraph = new Paragraph();
     paragraph.SetLeading(0f, 1.2f);
     paragraph.Alignment = alignment;
     paragraph.Font = font;
     paragraph.Add(content);
     doc.Add(paragraph);
 }
开发者ID:TeamMojito,项目名称:SupermarketsDatabaseClient,代码行数:9,代码来源:PdfReportert.cs

示例12: Convert

		/// <summary>
		/// Converts the specified simple text.
		/// </summary>
		/// <param name="simpleText">The simple text.</param>
		/// <returns></returns>
		public static iTextSharp.text.Chunk Convert(AODL.Document.Content.Text.SimpleText simpleText, iTextSharp.text.Font font)
		{
			try
			{
				return new iTextSharp.text.Chunk(simpleText.Text, font);
			}
			catch(Exception)
			{
				throw;
			}
		}
开发者ID:monsterlabs,项目名称:HumanRightsTracker,代码行数:16,代码来源:SimpleTextConverter.cs

示例13: AddString

        public void AddString(string str ,iTextSharp.text.Font font)
        {
            if(doc!=null)
            {
                Paragraph myParagraph = new Paragraph(str, font);
                doc.Add(myParagraph);

               // Chunk chunk = new Chunk(str + "金鑫珠宝销售记录单Hello world", FontFactory.getFont(FontFactory.COURIER, 20, iTextSharp.text.Font.ITALIC, new iTextSharp.text.Color(255, 0, 0)));
              //  doc.Add(chunk);
            }
        }
开发者ID:romanu6891,项目名称:fivemen,代码行数:11,代码来源:PdfHelper.cs

示例14: FillEvent

        public void FillEvent(string statementDate, int pageNumber, string title, iTextSharp.text.Image imgLogo)
        {
            if (statementDate != null && statementDate.Length > 0) {
                _statementDate = statementDate;
            } else {
                _statementDate = "";
            }

            _pageNumber = pageNumber;
            _title = title;
            _imgLogo = imgLogo;
        }
开发者ID:jwebb-vtg,项目名称:WSCIEMP,代码行数:12,代码来源:rptFieldContracting.cs

示例15: VisibleSignature

 /// <summary>
 /// Sets VisibleSignature's info.
 /// It can be null.
 /// </summary>                
 /// <param name="text">Sets the signature text identifying the signer.</param>        
 /// <param name="useLastPageToShowSignature">If it sets to true, value of the Page property will be ignored.</param>
 /// <param name="position">Position and dimension of the field in the page.</param>
 /// <param name="runDirection">Possible run direction values, left-to-right or right-to-left</param>
 /// <param name="pageNumberToShowSignature">The page to place the field. The fist page is 1.</param>
 /// <param name="imagePath">Signature's image. It can be null.</param>
 public void VisibleSignature(string text, bool useLastPageToShowSignature, iTextSharp.text.Rectangle position, PdfRunDirection runDirection, int pageNumberToShowSignature = 1, string imagePath = null)
 {
     _digitalSignature.VisibleSignature = new VisibleSignature
     {
         CustomText = text,
         UseLastPageToShowSignature = useLastPageToShowSignature,
         Position = position,
         RunDirection = runDirection,
         Font = _pdfReport.DataBuilder.PdfFont,
         ImagePath = imagePath,
         PageNumberToShowSignature = pageNumberToShowSignature
     };
 }
开发者ID:VahidN,项目名称:PdfReport,代码行数:23,代码来源:SignedFileBuilder.cs


注:本文中的iTextSharp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。