CSharp: QuestPDF create pdf file in donet core 6

article/2025/9/10 3:43:51
    /// <summary>/// geovindu, Geovin Du,涂聚文 Edit/// </summary>public class DuModel     {private string name;private int price, quantity;/// <summary>/// /// </summary>/// <param name="name"></param>/// <param name="price"></param>/// <param name="quantity"></param>public DuModel(string name,int price,int quantity){this.name = name;this.price = price;this.quantity = quantity;}/// <summary>/// /// </summary>public string Name{ get { return name; }set { name = value; }}/// <summary>/// /// </summary>public int Price{get { return price; }set { price = value; }}/// <summary>/// /// </summary>public int Quantity{get { return quantity; }set { quantity = value; }}/// <summary>/// /// </summary>/// <returns></returns>public override string ToString(){return $"{nameof(Name)}: {Name}, {nameof(Price)}: {Price}, {nameof(Quantity)}: {Quantity}";}}

    var titleStyle = TextStyle.Default.FontSize(36).SemiBold().FontColor(Colors.Blue.Medium).FontFamily("simhei");var duPdf = Document.Create(container =>{container.Page(page =>{page.Size(PageSizes.A4);page.Margin(2, Unit.Centimetre);page.PageColor(Colors.White);page.DefaultTextStyle(x => x.FontSize(20).SemiBold().FontColor(Colors.Blue.Medium).FontFamily("simhei"));page.Header().Text("geoVI studio捷为工作室")  .FontFamily("simhei")//中文,需定义中文字体否则出问题.SemiBold().FontSize(36).FontColor(Colors.Blue.Darken2);page.Content().PaddingVertical(1, Unit.Centimetre)                    .Column(x =>{x.Spacing(20);x.Item().Table(t =>{t.ColumnsDefinition(c =>{c.RelativeColumn();c.RelativeColumn(3);});t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Visual Studio").FontFamily("simhei");t.Cell().Border(1).Padding(5).Text("Start in debug mode with 'Hot Reload on Save' enabled.").FontFamily("simhei");t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Command line").FontFamily("simhei");t.Cell().Border(1).Padding(5).Text("Run 'dotnet watch'.").FontFamily("simhei");});x.Item().Text("Modify this line and the preview should show your changes instantly.").FontFamily("simhei");//表格x.Item().Table(table =>{//设置表头的列参数占比table.ColumnsDefinition(columns =>{columns.ConstantColumn(30);columns.RelativeColumn();columns.RelativeColumn();columns.RelativeColumn();columns.RelativeColumn();});// 表头table.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);});var list = new List<DuModel>();list.Add(new DuModel("小锅",20,1));list.Add(new DuModel("小刀", 2, 12));list.Add(new DuModel("小碗", 5, 13));list.Add(new DuModel("小筷", 20, 4));list.Add(new DuModel("小砧", 1, 100));//数据组合for (int i = 0; i < list.Count; i++){table.Cell().Element(CellStyle).Text(i + 1).FontFamily("simhei");table.Cell().Element(CellStyle).Text(list[i].Name).FontFamily("simhei");table.Cell().Element(CellStyle).AlignRight().Text($"{list[i].Price}$").FontFamily("simhei").Style(titleStyle);table.Cell().Element(CellStyle).AlignRight().Text(list[i].Quantity).FontFamily("simhei");table.Cell().Element(CellStyle).AlignRight().Text($"{list[i].Price * list[i].Quantity}$").FontFamily("simhei");static IContainer CellStyle(IContainer container){return container.BorderBottom(1).BorderColor(Colors.Grey.Lighten2).PaddingVertical(5);}}});});page.Footer().AlignCenter()                    .Text(x =>{x.Span("第 ");x.CurrentPageNumber();                      x.Span(" 页");x.Span("/共 ");x.TotalPages();x.Span(" 页");});});});// duPdf.ShowInPreviewer();string pathfile = @"geovindu" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";duPdf.GeneratePdf(pathfile);//duPdf.ShowInPreviewerAsync(2500);

输出:、

from:

 https://github.com/QuestPDF/
https://github.com/QuestPDF/QuestPDF-ExampleInvoice
https://github.com/QuestPDF/QuestPDF-Documentation

 


http://chatgpt.dhexx.cn/article/SteH0tOD.shtml

相关文章

DoNet开源项目-基于jQuery EasyUI的后台管理系统

本文转载于 石佳劼的博客&#xff0c;有问题请到原文咨询&#xff0c;原文连接。 博主在业余时间开发了一个简单的后台管理系统&#xff0c;其中用到了 jQuery EasyUI 框架&#xff0c;上次分享过系统布局&#xff0c;参考文章&#xff1a;jQuery EasyUI 后台管理系统布局分享…

脱离.Net Framework运行doNet程序的简单方法

脱离.Net Framework运行doNet程序的简单方法(Console) 在.Net Framework下&#xff0c;你就算写一个小小的控制台程序&#xff0c;哪怕只有几K大小&#xff0c;我们必须要安装一个几十M的Framework Runtime 当然&#xff0c;现在也有一个商业的解决方案&#xff0c;来脱离框架…

ubuntu安装dotnet

ubuntu安装.net 使用包安装 将 Microsoft 包签名密钥添加到受信任密钥列表&#xff0c;并添加包存储库。 wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb…

C#: //todo

最近在看前辈留下来的祖传代码&#xff0c;发现里面有很多//todo的标记&#xff0c;在此进行一下说明。 简单来说&#xff0c;//todo就类似于我们看书时使用的书签&#xff0c;当我们为了某种功能预留下编程的入口&#xff0c;但是短时间内又没时间完成代码时就可以留下一个//…

DONET开发

导读&#xff1a; 摘要&#xff1a;本文给出了在C#下利用正则表达式实现字符串搜索功能的方法&#xff0c;通过对.NET框架下的正则表达式的研究及实例分析&#xff0c;总结了正则表达式的元字符、规则、选项等。 关键字&#xff1a;正则表达式、元字符、字符串、匹配 1、正则表…

DoNet:浅淡对delegate的理解

1 前言 C#的相关文档&#xff0c;MSDN上其实已经很详细了&#xff0c;关于delegate的使用可以参 考MSDN上的文档https://msdn.microsoft.com/zh-cn/library/900fyy8e.aspx 2 官方示例 委托类型的声明与方法签名相似&#xff0c; 有一个返回值和任意数目任意类型的参数&…

DotNetBar

在网上看到一个开源的软件&#xff0c;下载之后发现其界面风格与office 2007类似&#xff0c;看着比较美观。于是下载下来了源代码&#xff0c;进行研究&#xff0c;在代码使用了DotNetBar组件。 简介 DotNetBar组件提供了office 2007风格的用户界面组件&#xff0c;相对于.n…

dotnet命令(不掌握)

安装好.Net Core SDK后就可以使用dotnet命令。 dotnet命令 命令解释dotnet命令本身&#xff0c;可以使用dotnet app.dll运行应用dotnet build生成.NET Core应用程序dotnet clean清理项目生成的输出dotnet new为给定的模板初始化C#或F#项目dotnet pack创建代码的NuGet包dotnet p…

Donate

如果感觉部分文章对你产生了很大的帮助&#xff0c;可以使用下面的支付宝链接进行捐助&#xff1a;You can buy me a coffee:) 可以去https://qr.alipay.com制作自己的支付二维码

细胞实例分割:DoNet: Deep De-overlapping Network for Cytology Instance Segmentation 论文阅读笔记

细胞实例分割&#xff1a;DoNet: Deep De-overlapping Network for Cytology Instance Segmentation 论文阅读笔记 一、Abstract二、引言三、相关工作细胞学实例分割遮挡实例分割 四、方法4.1 预览问题概述工作流程粗糙的 Mask 分割 4.2 解耦合和重组策略双路径区域分割模块 Du…

DotNET框架

1.1 .NET的诞生 DotNET(以下称.NET) 2002年&#xff0c;微软发布了.NET框架的第一个版本&#xff0c;称其实现了下一代系统的目标。.NET框架是一种比MFC和COM编程技术更抑制并面向对象的环境。 具备以下特点&#xff1a; 多平台 行业标准 安全…

donet学习笔记7(数据库的增删改查.dataview的运用)

&#xff11;&#xff0e;数据库前台设计&#xff1a;非常简单&#xff0c;建立一个表即可 create table person( pID varchar ( 10 ) primary key , personName varchar ( 20 ) not null , personSex varchar ( 2 ) ,) &#xff12;&#xff0e;前台设计&#xff1a; …

OpenCV学习笔记:KeyPoint和DMatch数据结构详解

近期事情太多了&#xff0c;课业也繁多&#xff0c;好久没更了&#xff0c;今天对OpenCV中经常用到的一些数据类型的结构进行一波分析&#xff0c;为自己做记录的同时也分享给大家。闲言少叙&#xff0c;开始操作。 一、KeyPoint 数据结构 angle //关键点的方向&#x…

The Center of Attention: Center-Keypoint Grouping via Attention for Multi-Person Pose Estimation

该论文发表于ICCV2021 本文是将Transformer应用于关键点分组的创新工作。实际上是自底向上方法中分组操作的优化&#xff0c;利用Transformer进行关键点分组&#xff0c;达到端到端训练与加快模型推理速度的效果。并且&#xff0c;在拥挤图像中&#xff0c;该方法能够拥有更好…

计算机视觉论文速递(六)GANet: A Keypoint-based Global Association Network for Lane Detection 基于关键点建模的全局关联网络

计算机视觉论文速递&#xff08;六&#xff09;GANet: A Keypoint-based Global Association Network for Lane Detection 基于关键点建模的全局关联网络 1. 摘要2. 方法动机3. 方法介绍3.1 车道线构建-全局关键点关联3.1.1关键点预测3.1.2 偏移量预测3.1.3 起始点采样 3.2 车道…

torchvision使用keypoint rcnn 进行人体关键点定位

系统&#xff1a;Windows 11 pytorch版本&#xff1a;1.11.0 torchvision版本&#xff1a;0.12.0 使用图片地址&#xff1a;vision/person1.jpg at main pytorch/vision GitHub 使用代码&#xff1a; import torch import torchvision.transforms from torchvision.model…

CenterNet: Keypoint Triplets for Object Detection

论文地址&#xff1a;https://arxiv.org/pdf/1904.08189.pdf 在本文中&#xff0c;作者将一个对象建模为一个单点&#xff0c;即其包围框的中心点。并使用关键点估计来找到中心点&#xff0c;并回归到所有其他对象属性&#xff0c;如大小、3D位置、方向&#xff0c;甚至姿势。C…

COCO数据集keypoint部分

COCO数据集总体格式如下&#xff1a; {"info": {...},"licenses": [...],"images": [...],"annotation": [...],"categories": [...], }coco数据集的使用&#xff1a; from pycocotools.coco import COCO import matplotl…

Rethinking Keypoint Representations: Modeling Keypoints and Poses as Objects for Multi-Person Human

该论文发表于ECCV2022 题目&#xff1a;重新思考关键点表征方法&#xff1a;将关键点和人体姿态作为目标建模以进行多人姿态估计 Abstract In keypoint estimation tasks such as human pose estimation,heatmap-based regression is the dominant approach despite possess…

[1] A Keypoint-based Global Association Network for Lane Detection

A Keypoint-based Global Association Network for Lane Detection 0. 摘要 概括车道线检测方法&#xff1a; &#xff08;1&#xff09;基于Anchor定位的方法&#xff0c;自顶向下根据路线图把预设定的Anchor回归到车道线上。缺点是对复杂车道线不够灵活&#xff1b; &#…