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

做电影网站服务器需求如何做攻击类型网站

做电影网站服务器需求,如何做攻击类型网站,手机软件商店,公司怎么建立自己网站QuestPDFQuestPDF是一个开源的工具库#xff0c;可以在.NET或者.Net Core中生成pdf文档它提供了一个布局引擎#xff0c;设计时考虑到了完整的分页支持以及灵活性要求#xff01;比市面上常见的Aspose和iTextSharp好用太多了#xff01;GitHub地址安装Install-Package Ques… QuestPDFQuestPDF是一个开源的工具库可以在.NET或者.Net Core中生成pdf文档它提供了一个布局引擎设计时考虑到了完整的分页支持以及灵活性要求比市面上常见的Aspose和iTextSharp好用太多了GitHub地址安装Install-Package QuestPDF例子简单例子生成Pdf文档一共分为三部分Header(页眉)Content内容,Footer页脚Document.Create(container  {container.Page(page {page.Size(PageSizes.A4);page.Margin(2, Unit.Centimetre);page.Background(Colors.White);page.DefaultTextStyle(x  x.FontSize(20));page.Header().Text(Hello PDF!).SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);page.Content().PaddingVertical(1, Unit.Centimetre).Column(x {x.Spacing(20);x.Item().Text(Placeholders.LoremIpsum());x.Item().Image(Placeholders.Image(200, 100));});page.Footer().AlignCenter().Text(x {x.Span(Page );x.CurrentPageNumber();});}); }) .GeneratePdf(hello.pdf);模板生成使用模板生成一共设计三个应用层的工作:文档Model(一组描述 PDF 文档内容的类)数据源(将域实体映射到文档模型的层)模板(描述如何可视化信息并将其转换为 PDF 文件的表示层)比如我们设计一个基本的发票信息 要设计一个购物清单一个卖家买家的地址以及发票编号等等 我们设计这样的3个Model类public class InvoiceModel{public int InvoiceNumber { get; set; }public DateTime IssueDate { get; set; }public DateTime DueDate { get; set; }public Address SellerAddress { get; set; }public Address CustomerAddress { get; set; }public ListOrderItem Items { get; set; }public string Comments { get; set; }}public class OrderItem{public string Name { get; set; }public decimal Price { get; set; }public int Quantity { get; set; }}public class Address{public string CompanyName { get; set; }public string Street { get; set; }public string City { get; set; }public string State { get; set; }public object Email { get; set; }public string Phone { get; set; }}Model定义好了之后我们就定义一些假数据来填充pdfpublic static class InvoiceDocumentDataSource{private static Random Random  new Random();public static InvoiceModel GetInvoiceDetails(){var items  Enumerable.Range(1, 8).Select(i  GenerateRandomOrderItem()).ToList();return new InvoiceModel{InvoiceNumber  Random.Next(1_000, 10_000),IssueDate  DateTime.Now,DueDate  DateTime.Now  TimeSpan.FromDays(14),SellerAddress  GenerateRandomAddress(),CustomerAddress  GenerateRandomAddress(),Items  items,Comments 测试备注};}private static OrderItem GenerateRandomOrderItem(){return new OrderItem{Name  商品,Price  (decimal)Math.Round(Random.NextDouble() * 100, 2),Quantity  Random.Next(1, 10)};}private static Address GenerateRandomAddress(){return new Address{CompanyName  测试商店,Street  测试街道,City  测试城市,State  测试状态,Email  测试邮件,Phone  测试电话};}}然后搭建我们的模板脚手架 我们要使用模板脚手架,就要定义一个实现IDocument接口的新类开始。该接口包含两个方法DocumentMetadata GetMetadata();void Compose(IDocumentContainer container);第一个是模板文档的一些基础信息 第二个是模板的容器 基于这些原则我们设计一个模板层类public class InvoiceDocument : IDocument{public InvoiceModel Model { get; }public InvoiceDocument(InvoiceModel model){Model  model;}public DocumentMetadata GetMetadata()  DocumentMetadata.Default;public void Compose(IDocumentContainer container){container.Page(page {page.PageColor(Colors.Red.Lighten1);page.Size(PageSizes.A4);page.Margin(10);//外边距page.Header().Height(100).Background(Colors.LightBlue.Lighten1);page.Content().Background(Colors.Grey.Lighten3);page.Footer().Height(50).Background(Colors.Grey.Lighten1);});} }pdf的page页面总是有三个元素:页眉,页脚内容。查看一下我们生成的文档到目前为止我们已经搭建了一个非常简单的页面其中每个部分都有不同的颜色或大小接下来我们来填充他的页眉,我们把数据源整理好了之后就可以调用Element方法填充public void Compose(IDocumentContainer container){container.Page(page {page.PageColor(Colors.Red.Lighten1);page.Size(PageSizes.A4);page.Margin(10);//外边距page.Header().Height(100).Background(Colors.LightBlue.Lighten1).Element(ComposeHeader);page.Content().Background(Colors.Grey.Lighten3);page.Footer().Height(50).Background(Colors.Grey.Lighten1);});}void ComposeHeader(IContainer container){var titleStyle  TextStyle.Default.FontSize(20).SemiBold().FontColor(Colors.Blue.Medium);container.Row(row {row.RelativeItem().Column(column {column.Item().Text($发票 #{Model.InvoiceNumber}).FontFamily(simhei).Style(titleStyle);column.Item().Text(text {text.Span(发行日期: ).SemiBold().FontFamily(simhei);text.Span(${Model.IssueDate:d}).FontFamily(simhei);});column.Item().Text(text {text.Span(支付日期: ).FontFamily(simhei).SemiBold();text.Span(${Model.DueDate:d}).FontFamily(simhei);});});});}最后我们来实现内容public void Compose(IDocumentContainer container){container.Page(page {page.PageColor(Colors.Red.Lighten1);page.Size(PageSizes.A4);page.Margin(10);//外边距page.Header().Height(100).Background(Colors.LightBlue.Lighten1).Element(ComposeHeader);page.Content().Background(Colors.Grey.Lighten3).Element(ComposeContent);page.Footer().Height(50).Background(Colors.Grey.Lighten1);});}void ComposeHeader(IContainer container){var titleStyle  TextStyle.Default.FontSize(20).SemiBold().FontColor(Colors.Blue.Medium);container.Row(row {row.RelativeItem().Column(column {column.Item().Text($发票 #{Model.InvoiceNumber}).FontFamily(simhei).Style(titleStyle);column.Item().Text(text {text.Span(发行日期: ).SemiBold().FontFamily(simhei);text.Span(${Model.IssueDate:d}).FontFamily(simhei);});column.Item().Text(text {text.Span(支付日期: ).FontFamily(simhei).SemiBold();text.Span(${Model.DueDate:d}).FontFamily(simhei);});});});}void ComposeContent(IContainer container){container.Table(table {// step 1table.ColumnsDefinition(columns {columns.ConstantColumn(25);columns.RelativeColumn(3);columns.RelativeColumn();columns.RelativeColumn();columns.RelativeColumn();});// step 2table.Header(header {header.Cell().Text(#).FontFamily(simhei);header.Cell().Text(商品).FontFamily(simhei);header.Cell().AlignRight().Text(价格).FontFamily(simhei);header.Cell().AlignRight().Text(数量).FontFamily(simhei);header.Cell().AlignRight().Text(总价).FontFamily(simhei);header.Cell().ColumnSpan(5).PaddingVertical(5).BorderBottom(1).BorderColor(Colors.Black);});// step 3foreach (var item in Model.Items){table.Cell().Element(CellStyle).Text(Model.Items.IndexOf(item)  1).FontFamily(simhei);table.Cell().Element(CellStyle).Text(item.Name).FontFamily(simhei);table.Cell().Element(CellStyle).AlignRight().Text(${item.Price}$).FontFamily(simhei);table.Cell().Element(CellStyle).AlignRight().Text(item.Quantity).FontFamily(simhei);table.Cell().Element(CellStyle).AlignRight().Text(${item.Price * item.Quantity}$).FontFamily(simhei);static IContainer CellStyle(IContainer container){return container.BorderBottom(1).BorderColor(Colors.Grey.Lighten2).PaddingVertical(5);}}});}在这些准备工作做完了之后我们就可以生成Pdf文档了var filePath  invoice.pdf;var model  InvoiceDocumentDataSource.GetInvoiceDetails();var document  new InvoiceDocument(model);document.GeneratePdf(filePath);当然还有很多好玩的功能今天就给大家讲个概念让大家对这个东西有个印象后面我会继续输出该库的相关功能。如果你们对该库感兴趣可以持续关注我微信公众号【黑哥聊dotNet】
http://www.sadfv.cn/news/7290/

相关文章:

  • 泉州网站建设公司首选做二手机网站
  • 简单的网站作业360建筑网官网招聘
  • 温岭市建设规划局网站仙游网站建设
  • 外贸网站设计与推广wordpress ajax登陆
  • 基于开源框架的网站开发花都网站建设公司天蝎信息
  • 南宁网站建公司吗站酷设计网页版
  • 机关网站建设情况汇报河北关键词排名推广
  • 秦皇岛网站建设岳阳云溪区建设局网站
  • 郑州移动网站建设手机能制作软件吗
  • 哪家网站游戏做的比较好的做网站安全联盟解
  • 石家庄建网站挣钱优帮云打开网站弹出图片代码
  • 益阳网站建设公司有哪些搜外友链
  • 哈尔滨网站建设模板策划网站标题 关键字
  • 以前做视频的网站吗北川建设局网站
  • 张家口市建设局网站如何做好线上推广和引流
  • 站长统计代码网站设计大小
  • 济源网站建设济源广州免费网站建设
  • 南通网站开发公司免费wordpress中文主题
  • wordpress网站源码h5海报是什么意思
  • 网站建设基本范例三位效果网站模版
  • 网站建设的主要步骤有哪些张圣志建盏个人简介
  • 作品集的个人网站怎么做做照片模板下载网站
  • 在自己的网站做外链杭州企业建设网站公司
  • 电脑网站建设在哪里专科学校有哪些好专业
  • 做军事网站的项目背景图片网站建设的好公司
  • 菏泽哪家网站设计公司好盘锦网站建设报价
  • 内蒙古建设 招聘信息网站wordpress添加广告位
  • 大秦建设集团有限责任公司官方网站网站平台建设基本情况
  • 学校网站建设解决方案网站入口门户
  • 网站购买域名吗营销型网站建设定制