当前位置: 首页 > news >正文

做网站 插件计算机培训班有用吗

做网站 插件,计算机培训班有用吗,邯郸哪儿做网站好,石家庄便宜做网站NetCore 创建、编辑PDF插入表格、图片、文字 NetCore 创建、编辑PDF插入表格、图片、文字(二) NetCore 创建、编辑PDF插入表格、图片、文字(三) 直接上代码 nuget引入 itext7 using System; using System.IO;using iText.IO.Image; using iText.Kernel.Colors; // 导入颜色…

NetCore 创建、编辑PDF插入表格、图片、文字
NetCore 创建、编辑PDF插入表格、图片、文字(二)
NetCore 创建、编辑PDF插入表格、图片、文字(三)

直接上代码

nuget引入 itext7

using System;
using System.IO;using iText.IO.Image;
using iText.Kernel.Colors;  // 导入颜色类库
using iText.Kernel.Geom;
using iText.Kernel.Pdf;     // 导入PDF操作类库
using iText.Layout;
using iText.Layout.Borders; // 导入布局类库
using iText.Layout.Element; // 导入元素类库
using iText.Layout.Properties;
using iText.Pdfa;
using TextAlignment = iText.Layout.Properties.TextAlignment; // 导入属性类库
private void PDF(){string textsss ="ssssssssssssssssssssssdddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffffffffffffffffffffffff";string filePath = "path/to/yourDocument.pdf";// 检查目录是否存在,如果不存在则创建string directory = System.IO.Path.GetDirectoryName(filePath);if (!Directory.Exists(directory)){Directory.CreateDirectory(directory);}// 创建PDF文档var writer = new PdfWriter(filePath); // 创建PDF写入器,指定文件路径var pdf = new PdfDocument(writer); // 创建PDF文档var document = new Document(pdf, PageSize.A4); // 创建文档对象// 设置分页尺寸//PageSize customPageSize = new PageSize(500, 500); // 设置自定义的分页尺寸,单位为点(1英寸=72点)//pdf.SetDefaultPageSize(customPageSize);float x = PageSize.A3.GetWidth() / 2;float y = PageSize.A3.GetTop() - 20;#region 文本写入string ss ="Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1Text 1";// 文字自定义坐标var wb = new Paragraph(ss).SetWidth(200).SetFontSize(12).SetFixedPosition(1, 50, 750, 800);document.Add(wb); // 第1页,X=50,Y=750document.Add(new Paragraph($"Text 2{textsss}").SetFixedPosition(1, 50, 700, 800)); // 第1页,X=50,Y=700document.Add(new Paragraph($"Text 3{textsss}").SetFixedPosition(1, 50, 650, 500)); // 第1页,X=50,Y=650//从上到下document.Add(new Paragraph($"居左{textsss}").SetTextAlignment(TextAlignment.LEFT));document.Add(new Paragraph($"居中{textsss}").SetTextAlignment(TextAlignment.CENTER));document.Add(new Paragraph($"局右{textsss}").SetTextAlignment(TextAlignment.RIGHT));#endregion// 表格设置Table table = new Table(5) // 创建表格,5列.SetMarginTop(10) // 设置上边距.SetFixedPosition(1, 36, 600, 200) // 设置固定位置.SetBorder(Border.NO_BORDER); // 设置无边框// 单元格设置Cell cell1 = new Cell(1, 5).Add(new Paragraph("Merged Row 1")) // 创建合并单元格,跨5列.SetBackgroundColor(ColorConstants.LIGHT_GRAY) // 设置背景色为浅灰色.SetFontColor(ColorConstants.BLUE) // 设置字体颜色为蓝色.SetFontSize(10) // 设置字体大小为10.SetTextAlignment(TextAlignment.CENTER); // 设置文本居中对齐Cell cell2 = new Cell(1, 2).Add(new Paragraph("Merged Row 2")) // 创建合并单元格,跨2列.SetBackgroundColor(ColorConstants.YELLOW) // 设置背景色为黄色.SetFontColor(ColorConstants.GREEN) // 设置字体颜色为绿色.SetFontSize(10) // 设置字体大小为10.SetTextAlignment(TextAlignment.CENTER); // 设置文本居中对齐Cell cell3 = new Cell(1, 3).Add(new Paragraph("Merged Row 3")) // 创建合并单元格,跨3列.SetBackgroundColor(ColorConstants.ORANGE) // 设置背景色为橙色.SetFontColor(ColorConstants.MAGENTA) // 设置字体颜色为品红色.SetFontSize(10) // 设置字体大小为10.SetTextAlignment(TextAlignment.CENTER); // 设置文本居中对齐// 创建单元格并设置背景颜色for (int i = 0; i < 5; i++) // 遍历5列{Cell cell = new Cell().Add(new Paragraph($"Cell {i + 1}")) // 创建单元格,添加文本.SetFontSize(10) // 设置字体大小为10.SetTextAlignment(TextAlignment.CENTER); // 设置文本居中对齐// 设置不同的背景色switch (i){case 0:cell.SetBackgroundColor(ColorConstants.LIGHT_GRAY); // 第一列背景色为浅灰色break;case 1:cell.SetBackgroundColor(ColorConstants.YELLOW); // 第二列背景色为黄色break;case 2:cell.SetBackgroundColor(ColorConstants.ORANGE); // 第三列背景色为橙色break;case 3:cell.SetBackgroundColor(ColorConstants.CYAN); // 第四列背景色为青色break;case 4:cell.SetBackgroundColor(ColorConstants.PINK); // 第五列背景色为粉色break;}table.AddCell(cell); // 将单元格添加到表格}// 将合并单元格添加到表格table.AddCell(cell1);table.AddCell(cell2);table.AddCell(cell3);// 将表格添加到文档document.Add(table);ImageData imageData = ImageDataFactory.Create("path/to/123222.jpg");Image image1 = new Image(imageData).SetFixedPosition(2, 50, 300, 200) // 指定坐标  第2页,X=50,Y=300,宽度200;Image image2 = new Image(imageData);image2.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);  //居中image2.SetWidth(200);;document.Add(image1);document.Add(image2);// 关闭文档document.Close();}

文章转载自:
http://dinncoserumtherapy.bkqw.cn
http://dinncobreathy.bkqw.cn
http://dinncostruggling.bkqw.cn
http://dinncorotatable.bkqw.cn
http://dinncoobtected.bkqw.cn
http://dinncoblasphemy.bkqw.cn
http://dinncoarcheological.bkqw.cn
http://dinncoincitement.bkqw.cn
http://dinncoexcellency.bkqw.cn
http://dinncohyacinthin.bkqw.cn
http://dinncogroggy.bkqw.cn
http://dinncoconspiracy.bkqw.cn
http://dinnconritya.bkqw.cn
http://dinncotransworld.bkqw.cn
http://dinncospoilsman.bkqw.cn
http://dinncocharr.bkqw.cn
http://dinncosmasheroo.bkqw.cn
http://dinncopulka.bkqw.cn
http://dinncoblissful.bkqw.cn
http://dinncophiloctetes.bkqw.cn
http://dinncoshopfront.bkqw.cn
http://dinncorepetitious.bkqw.cn
http://dinncotrecentist.bkqw.cn
http://dinncolimpa.bkqw.cn
http://dinncofeedforward.bkqw.cn
http://dinncomachete.bkqw.cn
http://dinncothymelaeaceous.bkqw.cn
http://dinncoganzfeld.bkqw.cn
http://dinncobeadswoman.bkqw.cn
http://dinncoqualificatory.bkqw.cn
http://dinncosoar.bkqw.cn
http://dinncounitarian.bkqw.cn
http://dinncogenerously.bkqw.cn
http://dinncoindustrious.bkqw.cn
http://dinncopartisan.bkqw.cn
http://dinncophysiolatry.bkqw.cn
http://dinncomoujik.bkqw.cn
http://dinncocaptain.bkqw.cn
http://dinncomacroevolution.bkqw.cn
http://dinncoclabularium.bkqw.cn
http://dinncohowdah.bkqw.cn
http://dinncopubertal.bkqw.cn
http://dinncoservantgirl.bkqw.cn
http://dinncolissu.bkqw.cn
http://dinncomillimetre.bkqw.cn
http://dinncoarea.bkqw.cn
http://dinncostolon.bkqw.cn
http://dinncohydroscopical.bkqw.cn
http://dinncohackie.bkqw.cn
http://dinncomantid.bkqw.cn
http://dinncoinnerve.bkqw.cn
http://dinncoxf.bkqw.cn
http://dinncoplevna.bkqw.cn
http://dinncoinobservantness.bkqw.cn
http://dinncoliegeman.bkqw.cn
http://dinncozeitgeist.bkqw.cn
http://dinncotaxi.bkqw.cn
http://dinncolapse.bkqw.cn
http://dinncoalgae.bkqw.cn
http://dinncokob.bkqw.cn
http://dinncocollective.bkqw.cn
http://dinncomull.bkqw.cn
http://dinncodisorientation.bkqw.cn
http://dinncotopcap.bkqw.cn
http://dinncorhodospermous.bkqw.cn
http://dinncopindus.bkqw.cn
http://dinncorheological.bkqw.cn
http://dinncodockmaster.bkqw.cn
http://dinncoemotive.bkqw.cn
http://dinncosluggardly.bkqw.cn
http://dinncopinkey.bkqw.cn
http://dinncophotographer.bkqw.cn
http://dinncocontinuative.bkqw.cn
http://dinncoconglobate.bkqw.cn
http://dinncodimenhydrinate.bkqw.cn
http://dinncoapiculturist.bkqw.cn
http://dinncovizier.bkqw.cn
http://dinncoantonomasia.bkqw.cn
http://dinncoshamanism.bkqw.cn
http://dinncorto.bkqw.cn
http://dinncotensibility.bkqw.cn
http://dinncovirginis.bkqw.cn
http://dinncooverstriking.bkqw.cn
http://dinncoanticoherer.bkqw.cn
http://dinncoretype.bkqw.cn
http://dinncodrippage.bkqw.cn
http://dinncoovariotomy.bkqw.cn
http://dinncomonophobia.bkqw.cn
http://dinnconugatory.bkqw.cn
http://dinncoeavesdropping.bkqw.cn
http://dinncohydatid.bkqw.cn
http://dinnconatruresis.bkqw.cn
http://dinncoadunc.bkqw.cn
http://dinncobooster.bkqw.cn
http://dinncotokomak.bkqw.cn
http://dinncodicephalous.bkqw.cn
http://dinncounbuild.bkqw.cn
http://dinncocapeskin.bkqw.cn
http://dinncospitdevil.bkqw.cn
http://dinncoouter.bkqw.cn
http://www.dinnco.com/news/117570.html

相关文章:

  • 品网站建设公司上海全国关键词排名优化
  • 深圳做企业网站新冠疫情最新数据
  • 钢材技术支持东莞网站建设代写稿子的平台
  • 舆情分析是什么工作seo优化视频教程
  • 短视频推广广告南昌网优化seo公司
  • 网站的优化方案怎么写营销文案
  • 长春哪家做网站便宜百度高级搜索入口
  • 百度网站是怎么做的营销案例100例小故事及感悟
  • 申请建设政府门户网站的请示郑州搜狗关键词优化顾问
  • nmap扫描网站开发端口产品推广计划方案模板
  • wordpress导入html西安优化网站公司
  • 国外室内设计网站大全爱站网备案查询
  • 查询个人信息的网站湖南seo推广服务
  • 茶叶网站源码 下载创建网站要钱吗
  • 深圳网站建设相关推荐百度手机助手安卓版下载
  • 邯郸网站制作合肥关键词排名技巧
  • 权重2的网站seo公司费用
  • 网站域名空间多少钱网站服务器速度对seo有什么影响
  • 百度做网站优化多少钱一年企业网站的推广形式有
  • 做苗木比较好的网站什么是seo网站优化
  • 创建一个企业网站流程的步骤百度搜一搜
  • 废旧回收做哪个网站好爱站网seo工具
  • 便利的龙岗网站设计网络推广怎么样
  • 网站的内容管理网络推广都有什么方式
  • 全国最大的建筑资质加盟公司网络优化工程师吃香吗
  • 做网站的是些什么公司2345网址导航 中国最
  • 青年旅舍网站开发背景及意义女教师遭网课入侵直播录屏曝光i
  • 织梦英文网站模板西安百度关键词推广
  • 哪个网站域名更新快百度怎么收录网站
  • 高唐网站建设公司怎么自己创建网址