当前位置:网站首页>iTextSharp 页面设置
iTextSharp 页面设置
2022-04-23 01:22:00 【心前阳光】
页面设置
页面尺寸
- new Document()
默认A4尺寸 默认页边距 上下左右是36磅 - new Document(Rectangle rect);
指定页面大小 默认页边距 上下左右 是36磅 - new Document(Rectangle rect,页边距左,右,上,下)
指定页面尺寸 和 页边距
4.SetPageSize(PageSize.A4)方法
设置页面尺寸为A4
注:PageSize有多个参数 A0-A10等等 - 默认页面是竖的 可以旋转页面为横向
new Document(PageSize.A4.Rotate());
注意:若要设置首页尺寸 需要在文档打开前设置 ;
一个页面内 只有首个 SetMargins 起作用
下一个页面 受到上一个页面中 最后一个 SetMargins 的影响
页边距
- 页边距 使用磅做为单位 1英寸=72磅
- SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom);
设置左右 上下页边距 - SetMarginMirroring(true);
水平方向镜像页边距 左右页边距交换 上下页边距不变 - SetMarginMirroringTopBottom(true);
竖直方向页边距 上下页边距交互 左右页边距不变
注意:如果要设置第一页的pdf页边距 需要在文档打开前设置
新页面
NewPage();打开新的页面
页面初始化
Opne方法会进行 页面初始化操作
因此若要设置 首页页面尺寸、页边距等,需要在Open方法之前进行操作;若在Open方法之后设置页面尺寸, 设置的页面尺寸只对首页之后的页面起作用。
实例
//1.页面尺寸 默认A4 页边距 36磅
Document document = new Document(PageSize.A4.Rotate());//横向
//2.页边距 影响所有页面 默认36磅
//一个页面内 只有首个 SetMargins 起作用
//下一个页面 受到上一个页面中 最后一个 SetMargins 的影响
document.SetMargins(36, 0, 36, 0);//单位磅 1英寸=72磅
PdfWriter.GetInstance(document, new FileStream("Chapter01.pdf", FileMode.Create));
document.Open();
document.Add(new Paragraph("*****************************************************"));
//3.镜像 水平页边距
document.SetMarginMirroring(true);//镜像 水平页边距 交换 左右页边距
document.SetMarginMirroringTopBottom(true);//镜像 竖直页边距 交换 顶部和底部页边距
//4.换页
//SetPageSize 要在换页前使用 才可以作用于新的页面
document.SetPageSize(PageSize.A2);
document.NewPage();
document.Add(new Paragraph("*****************************************************"));
document.Close();
版权声明
本文为[心前阳光]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43796392/article/details/124344905
边栏推荐
- The complete form of smart home and the development of "small homekit"
- Research and application of power monitoring system in sports training center
- Workplace PUA, five sins of managers
- Scope of define
- What is October 24th? Why are there no senior programmers in China in their fifties and sixties, while foreigners,,, Yu Nianyu Hui take you to celebrate the 1024 programmer Festival
- 深入解析Linux下的磁盘缓存机制与SSD的写入放大问题
- App uses the template message from WeChat official account for message push.
- Basic operation of Android local database | multi thread operation database | addition, deletion, modification and query of database | batch insertion into database | basic use of thread pool | Yu nia
- Gbase 8s Group by 功能介绍
- 轮转法分片
猜你喜欢
![[Ethernet switching security] - switch flow control / DHCP snooping / IP source guard](/img/cc/bbabc5621b8485d04ffa7d4d5fad2e.png)
[Ethernet switching security] - switch flow control / DHCP snooping / IP source guard

Hardware SPI analysis and configuration process of imx6ull bare metal development

【以太网交换安全】--- 交换机流量控制/DHCP Snooping/IP Source Guard

CVPR | 2022 | expressed by transformer learning multiple hypotheses! A new framework for 3D human pose estimation!

Here's the point. Have you mastered the most complete Web3 jargon guide?

How does zhiting connect Xiaomi smart speakers?

Get in the car, the era of intelligent database autonomy has come, and Tencent cloud database x AI has made a new breakthrough

Vs + C realizes that the form input box displays gray text by default

Practice and exploration of knowledge map visualization technology in meituan

Learning of gin framework -- golang
随机推荐
Practice and exploration of knowledge map visualization technology in meituan
Gbase 8s Group by 功能介绍
“自虐神器”一夜爆火:用手柄控制自己的脸,代码自取,后果自负
IMX6ULL裸机开发之硬件IIC分析及配置过程
Activity preview | on April 23, a number of wonderful openmldb sharing came, which lived up to the good time of the weekend!
Function encapsulation such as addition, deletion, modification and query of linked list (summary)
找数字(DFS)
Gbase 8s数据库日志简介及管理
那些咸鱼上买来的代码|ssm酒店客房管理系统|买来的源码是否真的可以使用|来自程序员的困惑|玉念聿辉|大丑村吴明辉
Introduction to gbase 8s checkpoint
Android本地数据库基础操作|多线程操作数据库|数据库的增删改查|批量插入数据库|线程池基础使用|玉念聿辉
Hardware SPI analysis and configuration process of imx6ull bare metal development
On regular expression matching cryptography
gin -get请求的小示例1-Handle处理GET请求
After ten years of testing experience, I have sorted out the most suitable software testing learning guide for you
Gbase 8t index
Daily practice (47): find different
Examples of branch and loop statements
Application of safe electricity management platform in Jingbian Museum safe electricity management system
Optical cat super account password, reset optical cat to obtain super account password