>

美洲杯在线投注_2019美洲杯外围投注[投注官网]

热门关键词: 美洲杯在线投注,2019美洲杯外围投注[投注官网]

C#使用iTextSharp给PDF添加水印,

- 编辑:美洲杯在线投注 -

C#使用iTextSharp给PDF添加水印,

冒泡排序,

 1 List<string> position = new List<string>();//坐标
 2 
 3 List<string> text = new List<string>();//text文本
 4         /// <summary>
 5         /// 冒泡排序
 6         /// </summary>
 7         /// <param name="dic">数据字典</param>
 8         private void sortDic(Dictionary<string, string> dic)
 9         {
10             int Flag = 1;  //标志位
11             //外循环每次把参与排序的最大数排在最后
12             for (int i = 1; i < position.Count; i  )
13             {
14                 if (Flag == 1)
15                 {
16                     string ls_value = string.Empty;  // 临时变量
17                     string ls_key = string.Empty;   // 临时变量
18                     Flag = 0;
19                     //内层循环负责对比相邻的两个数,并把最大的排在后面
20                     for (int j = 0; j < position.Count - i; j  )
21                     {
22                         //如果前 一个数大于后一个数,则交换两个数
23                         if (int.Parse(position[j].Split(',')[1]) > int.Parse(position[j   1].Split(',')[1]))
24                         {                            
25                             ls_key = text[j   1];
26                             ls_value = position[j   1];
27 
28                             text[j   1] = text[j];
29                             text[j] = ls_key;
30                             position[j   1] = position[j];
31                             position[j] = ls_value;
32                             Flag = 1;
33                         }
34                     }
35                 }
36             }
37             for (int i = 0; i < position.Count; i  )
38             {
39                 dic.Add(text[i], position[i]);
40             }
41         }

 

http://www.bkjia.com/C_jc/1261036.htmlwww.bkjia.comtruehttp://www.bkjia.com/C_jc/1261036.htmlTechArticle冒泡排序, 1 List string position = new List string (); // 坐标 2 3 List string text = new List string (); // text文本 4 /// summary 5 /// 冒泡排序 6 /// /summary 7 //...

C#使用iTextSharp给PDF添加水印,

代码:

篮球世界杯在线投注 1/// <summary> /// 添加普通偏转角度文字水印 /// </summary> public static void SetWatermark(string filePath, string text) { PdfReader pdfReader = null; PdfStamper pdfStamper = null; string tempPath = Path.GetDirectoryName(filePath) Path.GetFileNameWithoutExtension(filePath) "_temp.pdf"; try { pdfReader = new PdfReader(filePath); pdfStamper = new PdfStamper(pdfReader, new FileStream(tempPath, FileMode.Create)); int total = pdfReader.NumberOfPages 1; iTextSharp.text.Rectangle psize = pdfReader.GetPageSize(1); float width = psize.Width; float height = psize.Height; PdfContentByte content; BaseFont font = BaseFont.CreateFont(@"C:WINDOWS篮球世界杯在线投注,FontsSIMFANG.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); PdfGState gs = new PdfGState(); for (int i = 1; i < total; i ) { content = pdfStamper.GetOverContent(i);//在内容上方加水印 //content = pdfStamper.GetUnderContent(i);//在内容下方加水印 //透明度 gs.FillOpacity = 0.3f; content.SetGState(gs); //content.SetGrayFill(0.3f); //开始写入文本 content.BeginText(); content.SetColorFill(BaseColor.GRAY); content.SetFontAndSize(font, 30); content.SetTextMatrix(0, 0); content.ShowTextAligned(Element.ALIGN_CENTER, text, width - 120, height

  • 120, -45); //content.SetColorFill(BaseColor.BLACK); //content.SetFontAndSize(font, 8); //content.ShowTextAligned(Element.ALIGN_CENTER, waterMarkName, 0, 0, 0); content.EndText(); } } catch (Exception ex) { throw ex; } finally { if (pdfStamper != null) pdfStamper.Close(); if (pdfReader != null) pdfReader.Close(); System.IO.File.Copy(tempPath, filePath, true); System.IO.File.Delete(tempPath); } } View Code

 

http://www.bkjia.com/C_jc/1163829.htmlwww.bkjia.comtruehttp://www.bkjia.com/C_jc/1163829.htmlTechArticleC#使用iTextSharp给PDF添加水印, 代码: /// summary /// 添加普通偏转角度文字水印 /// /summary public static void SetWatermark( string filePath, string text){...

本文由计算机教程发布,转载请注明来源:C#使用iTextSharp给PDF添加水印,