ningshuxia
2023-03-14 076301ec9c2c2fc117a062231c4c5f0e8ea6c23c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Text;
 
namespace IStation.DataFile
{
#pragma warning disable CA1416 // 验证平台兼容性
    /// <summary>
    /// 
    /// </summary>
    public class EnginePumpDayReportV1Helper
    {
        ///(1单元格内容,2字体,3占位行,4占位列,5行高,6行位置)
        Document _document;
        PdfWriter _writer;
        //BaseFont _baseFont_general = null;//常规字体
        BaseFont _baseFont_spec_char;//特殊字符字体
        iTextSharp.text.Font _fontSize8;
        iTextSharp.text.Font _fontSize9_bold;
        iTextSharp.text.Font _fontSize13_bold;
        iTextSharp.text.Font _fontSize11;
 
        int _currentPage = 0;
 
        /// <summary>
        /// 调用打印PDF
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="paras"></param>
        /// <param name="Msg"></param>
        /// <returns></returns>
        public bool Create(string filePath, EnginePumpDayReportParasV1 paras, out string Msg)
        {
            if (filePath == "") 
            {
                Msg = "路径为空";
                return false;
            }
            if (paras == null)
            {
                Msg = "参数为空";
                return false;
            }
            InitialFont();
            //初始化标题中的LOGO图片
            InitialTitleLogoImage();
            MemoryStream strem = new MemoryStream();
 
            _document = new Document(iTextSharp.text.PageSize.A4);
            _document.SetMargins(-20, -20, 20,20);
            _writer = PdfWriter.GetInstance(_document, new FileStream(filePath, FileMode.Create));
 
            _document.Open();
            if (this.CreateProductInfoPage(paras))
                Msg = "打印成功";
            else
                Msg = "打印失败";
            _document.Close();
            return true;
        }
 
        //字体
        private void InitialFont()
        {
            string fileTtc_simsun = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fonts\\msyhl.ttc");
            if (!System.IO.File.Exists(fileTtc_simsun))
            {
                if (System.IO.File.Exists(@"C:\Windows\Fonts\msyhl.ttc"))
                {
                    fileTtc_simsun = @"C:\Windows\Fonts\msyhl.ttc";
                }
                else
                {
                    if (System.IO.File.Exists(@"C:\Windows\Fonts\msyhl.ttc"))
                    {
                        fileTtc_simsun = @"C:\Windows\Fonts\msyhl.ttc";
                    }
                }
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                _baseFont_spec_char = BaseFont.CreateFont(fileTtc_simsun + ",1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                //读取ttc字体                                                                                                        
                //BaseFont.CreateFont 的第一个参数,在字体文件后不一定需要跟上“,1”。                                                                                                    
                //这取决于使用的字体文件是否支持多字体。例如simsun.ttc 包含了“宋体”和“新宋体”两套字体,                                                                                   
                //那么如果要使用这个字体文件,就必须指明使用哪一套字体,序号从0开始。                                                                                               
                //但如果使用的字体文件只有一套字体,则一定不能加“,0”。否则,无论是多加还是少加,都会报错。                                                                        
                //要想知道字体文件是否是多套字体,只需双击打开字体文件,如果有导航的>>和<<按钮,则是有多套字体,否则就不是。                                                                              
                //TTC是几个TTF合成的字库,安装后字体列表中会看到两个以上的字体。
            }
            if (_baseFont_spec_char == null)
                return;
            _fontSize8 = new iTextSharp.text.Font(_baseFont_spec_char, 8);
            _fontSize9_bold = new iTextSharp.text.Font(_baseFont_spec_char, 9, iTextSharp.text.Font.BOLD);
            _fontSize13_bold = new iTextSharp.text.Font(_baseFont_spec_char, 13, iTextSharp.text.Font.BOLD);
            _fontSize11 = new iTextSharp.text.Font(_baseFont_spec_char, 11);
        }
 
        #region LOGO图片
        System.Drawing.Image _imgTitleCorpLogo = null;//表头的LOGO
 
        /// <summary>
        /// LOGO
        /// </summary>
        public void InitialTitleLogoImage()
        {
            //如果Data文件夹下有就优先
            string strLogoFullPath = string.Format("{0}\\SelectReportTitleLogo.png", 1);
            if (strLogoFullPath == null)
                return;
            if (System.IO.File.Exists(strLogoFullPath))
            {
                _imgTitleCorpLogo = System.Drawing.Image.FromFile(strLogoFullPath);
                return;
            }
 
            strLogoFullPath = string.Format("{0}\\CorpLogo.png", 1);
            if (System.IO.File.Exists(strLogoFullPath))
            {
                _imgTitleCorpLogo = System.Drawing.Image.FromFile(strLogoFullPath);
                return;
            }
 
            //没有就搜索Infomation文件夹
            strLogoFullPath = string.Format("{0}Infomation\\CorpLogo.png", AppDomain.CurrentDomain.BaseDirectory);
            if (System.IO.File.Exists(strLogoFullPath))
            {
                _imgTitleCorpLogo = System.Drawing.Image.FromFile(strLogoFullPath);
            }
        }
        #endregion
 
        /// <summary>
        /// PDF生成
        /// </summary>
        public bool CreateProductInfoPage(EnginePumpDayReportParasV1 paras)
        {
            if (paras == null)
                return false;
            _document.NewPage();
            _currentPage++;
            //var titlePage = "设备健康状态评估日报告";//
            CreateProductTable(paras);
            //this.CreateReportNotesTable(titlePage);
            CreateReportNotesTable();
            CreateProductInfoTable(paras.ErangeList);
            PdfPTable table1 = new PdfPTable(3);
            float[] widths = { 80, 120, 300 };
            table1.SetWidths(widths);
            PdfPCell cell = new PdfPCell();
 
 
 
            cell = this.CreateCell2("设备健康状态评估日报告" + ":", _fontSize8, 1, 1);
            table1.AddCell(cell);
            _document.Add(table1);
            CreatePropTable();
 
            return true;
        }
 
        /// <summary>
        /// 
        /// </summary>
        public void CreatePropTable()
        {
            List<int> _allPartPropList = new List<int>();
            _allPartPropList.Add(10);
            PdfPTable table = new PdfPTable(2);
            float[] widths = { 300, 300 };
            table.SetWidths(widths);
            PdfPCell cell = new PdfPCell();
            int endIndex = 0;
            cell.DisableBorderSide(8);
            cell.AddElement(this.PropertyTable(38, 0, out endIndex));
            table.AddCell(cell);
            if (endIndex < _allPartPropList.Count && endIndex > -1)
            {
                cell = new PdfPCell();
                cell.DisableBorderSide(4);
                cell.AddElement(this.PropertyTable(38, endIndex, out endIndex));
                table.AddCell(cell);
            }
            _document.Add(table);
 
 
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="displayRow"></param>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        /// <returns></returns>
        public PdfPTable PropertyTable(int displayRow, int startIndex, out int endIndex)
        {
            PdfPTable table = new PdfPTable(2);
            float[] widths = { 300, 300 };
            table.SetWidths(widths);
            PdfPCell cell = new PdfPCell();
            int row = 0;//记录循环的行数
            string groupName = string.Empty;
 
            if (row != 0)
            {
                cell = CreateCell2("", _fontSize9_bold, 2, 1, 10, 15);
                table.AddCell(cell);
                row++;
            }
            groupName = "名称";
            cell = CreateCell1("名称", _fontSize9_bold, 2, 1, 13, 15);
            table.AddCell(cell);
            row++;
 
            cell = CreateCell2("名称", _fontSize8, 1, 1, 13, 0, iTextSharp.text.Rectangle.ALIGN_LEFT, Element.ALIGN_LEFT, true);
            cell.PaddingLeft = 8;
            table.AddCell(cell);
            cell = CreateCell2("名称", _fontSize8, 1, 1, 13, 0);
            cell.PaddingLeft = 8;
            table.AddCell(cell);
            row++;
 
 
            endIndex = -1;
            return table;
        }
 
        private PdfPCell AddPicture(System.Drawing.Image image,
            int colspan, int rowspan,
            float cellHeight,
            int BorderWidthLeft = -1, int BorderWidthRight = -1,
            int BorderWidthTop = -1, int BorderWidthBottom = -1, float fixHeight = -1)
        {
            if (image == null)
                return null;
            PdfPCell cell = new PdfPCell();
            cell.Colspan = colspan;
            cell.Rowspan = rowspan;
            cell.MinimumHeight = cellHeight;
            cell.FixedHeight = cellHeight;
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            if (BorderWidthLeft >= 0)
                cell.BorderWidthLeft = BorderWidthLeft;
            if (BorderWidthLeft >= 0)
                cell.BorderWidthRight = BorderWidthRight;
            if (BorderWidthTop >= 0)
                cell.BorderWidthTop = BorderWidthTop;
            if (BorderWidthBottom >= 0)
                cell.BorderWidthBottom = BorderWidthBottom;
            if (fixHeight > 0)
                cell.FixedHeight = fixHeight;
 
 
            while (image.Width > 1800)
            {
                image = image.GetThumbnailImage(Convert.ToInt32(image.Width * 0.9), Convert.ToInt32(image.Height * 0.9), () => { return false; }, IntPtr.Zero);
            }
 
            var imgTextSharp = iTextSharp.text.Image.GetInstance(image, BaseColor.White);
            imgTextSharp.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
            cell.Image = imgTextSharp;
            return cell;
        }
 
        /// <summary>
        /// 设备信息
        /// </summary>
        //
        public void CreateProductTable(EnginePumpDayReportParasV1 paras)
        {
            if (paras == null)
                return;
            PdfPTable table = new PdfPTable(4);
            PdfPCell cell = new PdfPCell();
            float[] widths = new float[] { 30, 90, 30, 90 };
 
 
            cell = this.CreateCell2("设备健康状况日报告", _fontSize13_bold, 4, 1, 40,0 , iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("设备状况", _fontSize13_bold, 4, 1, 30,0,  iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("机泵名称", _fontSize9_bold, 1, 1, 20, 0,iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.EnginePumpName, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("机泵编码", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.EnginePumpNo, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("报告日期", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.ReportDay.ToString(), _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("运行时间", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.RunTime, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("供水量", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.WaterSupply, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("耗电", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.ConsumePower, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("平均效率", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.AverageEfficiency, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2("标准煤", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            cell = this.CreateCell2(paras.StandardCoal, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            table.SetWidths(widths);
            _document.Add(table);
        }
 
        /// <summary>
        /// 详细描述
        /// </summary>
        public void CreateReportNotesTable()
        {
            PdfPTable table = new PdfPTable(3);
            PdfPCell cell = new PdfPCell();
            float[] widths = new float[] { 40, 40, 240 };
 
            cell = this.CreateCell2("报告注释", _fontSize11, 0, 6, 45, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
 
            cell = this.CreateCell2("优秀", _fontSize11, 1, 1, 45, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Green;
            table.AddCell(cell);
            cell = this.CreateCell2("表示设备状态极好,无任何异常迹象,无需任何处理措施;", _fontSize11, 2, 1, 45);
            table.AddCell(cell);
      
            cell = this.CreateCell2("良好", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Cyan;
            table.AddCell(cell);
            cell = this.CreateCell2("表示设备状态正常,具有某些早期故障征兆,振动很小但稳定,无需任何处理措施,常规监控即可;", _fontSize11, 2, 1, 60);
            table.AddCell(cell);
 
            cell = this.CreateCell2("观察", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Yellow;
            table.AddCell(cell);
            cell = this.CreateCell2("表示设备设备状态基本正常,振动有所增大但仍在允许范围内 某些早期故障征兆有进一步发展,需要加强监控观察运行;", _fontSize11, 2, 1, 45);
            table.AddCell(cell);
 
            cell = this.CreateCell2("警告", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Orange;
            table.AddCell(cell);
            cell = this.CreateCell2("表示设备振动或温度测量值偏大,超过了ISO 10816-7和ISO 10816-3的一级阈值,需要在适当的时候对设备进行检查;", _fontSize11, 2, 1, 45);
            table.AddCell(cell);
 
            cell = this.CreateCell2("危险", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Red;
            table.AddCell(cell);
            cell = this.CreateCell2("表示设备振动或温度测量值偏大,超过了ISO 10816-7和ISO 10816-3的一级阈值,需要在适当的时候对设备进行检查;", _fontSize11, 2, 1, 45);
            table.AddCell(cell);
 
            cell = this.CreateCell2("离线", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
            cell.BackgroundColor = BaseColor.Gray;
            table.AddCell(cell);
            cell = this.CreateCell2("表示该测点不在正常测量中,可能的情况包括采集设备故障、设备停机、非ok、已拆除等;", _fontSize11, 2, 1, 45);
            table.AddCell(cell);
 
            table.SetWidths(widths);
            _document.Add(table);
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pairs"></param>
        public void CreateProductInfoTable(List<KeyValuePair<string, string>> pairs)
        {
            if (pairs == null)
                return;
 
            PdfPTable table = new PdfPTable(4);
            PdfPCell cell = new PdfPCell();
            float[] widths = new float[] { 30, 90, 30, 90 };
            cell = this.CreateCell2("效率区间", _fontSize13_bold, 4, 1, 30, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
            table.AddCell(cell);
            foreach (var pair in pairs)
            {
 
                cell = this.CreateCell2("效率", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
                table.AddCell(cell);
                cell = this.CreateCell2(pair.Key, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
                table.AddCell(cell);
                cell = this.CreateCell2("时间", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
                table.AddCell(cell);
                cell = this.CreateCell2(pair.Value, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
                table.AddCell(cell);
                table.SetWidths(widths);
            }
            _document.Add(table);
        }
 
        ///// <summary>
        ///// 
        ///// </summary>
        ///// <param name = "pairs" ></ param >
        //public void CreateProductInfoTable(List<KeyValuePair<string, string>> pairs)
        //{
        //    if (pairs == null)
        //        return;
 
        //    PdfPTable table = new PdfPTable(4);
        //    PdfPCell cell = new PdfPCell();
        //    float[] widths = new float[] { 30, 90, 30, 90 };
        //    cell = this.CreateCell2("效率区间", _fontSize13_bold, 4, 1, 30, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    foreach (var pair in pairs)
        //    {
 
        //        cell = this.CreateCell2("效率", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //        table.AddCell(cell);
        //        cell = this.CreateCell2(pair.Key, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //        table.AddCell(cell);
        //        cell = this.CreateCell2("时间", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //        table.AddCell(cell);
        //        cell = this.CreateCell2(pair.Value, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //        table.AddCell(cell);
        //        table.SetWidths(widths);
        //    }
        //    _document.Add(table);
        //}
 
 
 
 
 
        /////// <summary>
        /////// 设备信息
        /////// </summary>
        //////
        ////public void CreateProductTable(EnginePumpDayReportParasV1 paras)
        ////{
        ////    if (paras == null)
        ////        return;
        ////    PdfPTable table = new PdfPTable(2);
        ////    PdfPCell cell = new PdfPCell();
        ////    float[] widths = new float[] { 37, 260 };
 
 
        ////    cell = this.CreateCell2("设备健康状况日报告", _fontSize13_bold, 2, 1, 40, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2("机泵名称", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2(paras.EnginePumpName, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2("机泵编码", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2(paras.EnginePumpNo, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2("报告日期", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2(paras.ReportDay.ToString(), _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2("运行时间", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    cell = this.CreateCell2(paras.RunTime, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    table.AddCell(cell);
        ////    //cell = this.CreateCell2("供水量", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2(paras.WaterSupply, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2("耗电", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2(paras.ConsumePower, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2("平均效率", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2(paras.AverageEfficiency, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2("标准煤", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    //cell = this.CreateCell2(paras.StandardCoal, _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        ////    //table.AddCell(cell);
        ////    table.SetWidths(widths);
        ////    _document.Add(table);
        ////}
 
 
 
 
        ///// <summary>
        ///// 报告信息
        ///// </summary>
        ///// <param name="name"></param>
        //public void CreateReportNotesTable(string name)
        //{
        //    PdfPTable table = new PdfPTable(3);
        //    PdfPCell cell = new PdfPCell();
        //    float[] widths = new float[] { 40, 40,240 };
 
        //    cell = this.CreateCell2("报告注释", _fontSize11, 0, 6, 45, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("优秀", _fontSize11, 1, 1, 45, 0,iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Green;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示设备状态极好,无任何异常迹象,无需任何处理措施;", _fontSize11, 2, 1, 45, 2);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("良好", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Cyan;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示设备状态正常,具有某些早期故障征兆,振动很小但稳定,无需任何处理措施,常规监控即可;", _fontSize11, 2, 1, 45, 2);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("观察", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Yellow;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示设备设备状态基本正常,振动有所增大但仍在允许范围内 某些早期故障征兆有进一步发展,需要加强监控观察运行;", _fontSize11, 2, 1, 45, 2);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("警告", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Orange;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示设备振动或温度测量值偏大,超过了ISO 10816-7和ISO 10816-3的一级阈值,需要在适当的时候对设备进行检查;", _fontSize11, 2, 1, 45, 2);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("危险", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Red;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示设备振动或温度测量值偏大,超过了ISO 10816-7和ISO 10816-3的一级阈值,需要在适当的时候对设备进行检查;", _fontSize11, 2, 1, 45, 0);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("离线", _fontSize11, 1, 1, 45, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.LightGray;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("表示该测点不在正常测量中,可能的情况包括采集设备故障、设备停机、非ok、已拆除等;", _fontSize11, 2, 1, 45, 0);
        //    table.AddCell(cell);
 
        //    cell.Rowspan = 4;
        //    table.SetWidths(widths);
        //    _document.Add(table);
        //}
 
        ///// <summary>
        ///// 设备详情
        ///// </summary>
        ///// <param name="name"></param>
        //public void CreateProductInfoTable()
        //{
        //    PdfPTable table = new PdfPTable(3);
        //    PdfPCell cell = new PdfPCell();
        //    float[] widths = new float[] { 40, 40, 240 };
 
        //    ///(1单元格内容,2字体,3占位行,4占位列,5行高,6行位置)
        //    cell = this.CreateCell2("设备信息", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("机组名称", _fontSize9_bold, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("设备编号", _fontSize9_bold, 1, 1, 20, 2, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("※※※※※※※※※※※※※※※※分割线※※※※※※※※※※※※※※※※※※", _fontSize11, 3, 1, 25, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("设备名称", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("21" + "日状态", _fontSize11, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("设备历史信息", _fontSize9_bold, 1, 1, 20, 2, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("启动次数", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("1", _fontSize11, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("停机次数", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("设备部位详细历史状态", _fontSize9_bold, 3, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("位置", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("状态", _fontSize9_bold, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("位置", _fontSize9_bold, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("德克萨斯", _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("OK", _fontSize11, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Cyan;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("德克萨斯", _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("德克萨斯", _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("OK", _fontSize11, 1, 1, 20, 1, iTextSharp.text.Rectangle.ALIGN_CENTER);
        //    cell.BackgroundColor = BaseColor.Cyan;
        //    table.AddCell(cell);
        //    cell = this.CreateCell2("德克萨斯", _fontSize11, 1, 1, 20, 0, iTextSharp.text.Rectangle.ALIGN_CENTER);
 
        //    table.AddCell(cell);
 
 
 
        //    cell.Rowspan = 4;
        //    table.SetWidths(widths);
        //    _document.Add(table);
        //}
 
        ////添加水印
        //public void AddWatermark()
        //{
        //    if (_isPrintCorpWaterMark)
        //    {
 
        //        var waterMarkLogoFile = System.IO.Path.Combine(SPump.GlobeParas.DataFolder, "SelectReportWaterMark.png");
        //        if (System.IO.File.Exists(waterMarkLogoFile))
        //        {
        //            PdfContentByte cb = _writer.DirectContent;
        //            iTextSharp.text.Rectangle psize = _document.PageSize;
        //            float width = psize.Width;
        //            float height = psize.Height;
        //            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(waterMarkLogoFile);
        //            image.ScalePercent(50);
 
        //            //水印的位置
        //            //var i = image.Width;
        //            image.SetAbsolutePosition(width / 2 - image.Width / 4, height / 2 - image.Height / 4);
        //            cb.AddImage(image);
        //        }
 
 
 
        //    }
 
 
 
        //    if (!string.IsNullOrEmpty(RefWaterMarkText))
        //    {
        //        Font font = new Font(Font.FontFamily.UNDEFINED, 30, Font.BOLD, new iTextSharp.text.BaseColor(100, 200, 200, 50));
 
        //        Phrase p = new Phrase(RefWaterMarkText, font);
        //        ColumnText.ShowTextAligned(_writer.DirectContent, Element.ALIGN_CENTER, p, _document.PageSize.Width - 100, _document.PageSize.Height - 100, 0);
 
        //    }
 
 
        //}
 
        //为英文时首字母大写
        private PdfPCell CreateCell1(string name,
           iTextSharp.text.Font font = null, int col = 1, int row = 1, float rowHeight = 15, int disableNum = 0, int r = iTextSharp.text.Rectangle.ALIGN_LEFT)
        {
            Paragraph table_t = null;
            PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
            if (font == null)
                font = _fontSize8;
            if (name == null)
            {
                name = "";
            }
 
            table_t = new Paragraph(name, font);
            table_t.Leading = 9;
            cell.Colspan = col;
            cell.Rowspan = row;
            cell.MinimumHeight = rowHeight;
            cell.FixedHeight = rowHeight;
            cell.DisableBorderSide(disableNum);
            cell.Padding = 0;
            cell.PaddingLeft = 3;
            cell.UseAscender = true;
            cell.UseDescender = true;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;//垂直居中
            table_t.Alignment = r;
            cell.AddElement(table_t);
 
            return cell;
        }
 
        //绘制文本(可能有特殊字符)
        private PdfPCell CreateCell2(string name,
            iTextSharp.text.Font font = null,
            int col = 1, int row = 1, float rowHeight = 30, int disableNum = 0,
            int r = iTextSharp.text.Rectangle.ALIGN_LEFT, int Paragraph = Element.ALIGN_LEFT, bool b = false, int strLength = 26)
        {
            Paragraph table_t = null;
            PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
            if (font == null)
                font = _fontSize8;
            if (name == null)
            {
                name = "";
            }
            if (name.Length > 27 && b && name.Length > strLength)
            {
                name = name.Substring(0, strLength);
            }
            table_t = new Paragraph(name, font);
            table_t.Alignment = Element.ALIGN_LEFT;
 
            cell.Colspan = col;
            cell.Rowspan = row;
            
 
            cell.MinimumHeight = rowHeight;
            cell.FixedHeight = rowHeight;
            cell.DisableBorderSide(disableNum);
            cell.Padding = 0;
            cell.PaddingLeft = 3;
            cell.UseAscender = true;
            cell.UseDescender = true;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;//垂直居中
            table_t.Alignment = r;
            cell.AddElement(table_t);
 
            return cell;
        }
 
 
        private PdfPCell CreateCell(double value,
            iTextSharp.text.Font font = null, int col = 1, int row = 1, float rowHeight = 15, int disableNum = 0, int r = iTextSharp.text.Rectangle.ALIGN_LEFT)
        {
            string value_v = string.Empty;
            Paragraph table_t = null;
            PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
            if (font == null)
                font = _fontSize8;
            if (value >= 0)
            {
                value_v = Math.Round(value, 4).ToString();
            }
            table_t = new Paragraph(value_v, font);
            table_t.Leading = 9;
            cell.Colspan = col;
            cell.Rowspan = row;
 
            cell.MinimumHeight = rowHeight;
            cell.FixedHeight = rowHeight;
            cell.DisableBorderSide(disableNum);
            cell.Padding = 0;
            cell.PaddingLeft = 3;
            cell.UseAscender = true;
            cell.UseDescender = true;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;//垂直居中
            table_t.Alignment = r;
            cell.AddElement(table_t);
            return cell;
        }
        //约分 
        private PdfPCell CreateCellReduce(double value,
            iTextSharp.text.Font font = null, int col = 1, int row = 1, float rowHeight = 15, int disableNum = 0, int r = iTextSharp.text.Rectangle.ALIGN_LEFT)
        {
            string value_v = string.Empty;
            Paragraph table_t = null;
            PdfPCell cell = new iTextSharp.text.pdf.PdfPCell();
            if (font == null)
                font = _fontSize8;
            if (value >= 0)
            {
                value_v = Math.Round(value, 2).ToString();
            }
            table_t = new Paragraph(value_v, font);
            table_t.Leading = 9;
            cell.Colspan = col;
            cell.Rowspan = row;
 
            cell.MinimumHeight = rowHeight;
            cell.FixedHeight = rowHeight;
            cell.DisableBorderSide(disableNum);
            cell.Padding = 0;
            cell.PaddingLeft = 3;
            cell.UseAscender = true;
            cell.UseDescender = true;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;//垂直居中
            table_t.Alignment = r;
            cell.AddElement(table_t);
            return cell;
        }
 
        //画单元格方法
        private PdfPTable CreateTable(int spanNum, float percentage = 100)//建立表格
        {
            PdfPTable table1 = new PdfPTable(spanNum);//将表格分为10列
 
            table1.WidthPercentage = percentage;//表格所占界面的百分比
            return table1;
        }
    }
#pragma warning restore CA1416 // 验证平台兼容性
}