当前位置:网站首页>C#/VB.NET to add more lines more columns image watermark into the Word document
C#/VB.NET to add more lines more columns image watermark into the Word document
2022-08-02 10:40:00 【51CTO】
在WordWhen adding a watermark inside,A common situation is to only support adding a watermark effect to the entire page;For the effect that needs to cover the entire page with the watermark, you can refer to the method in this article.This article introduces a more flexible way to add multiple rows and multiple columns(平铺)图片水印到Word文档.下面是详细方法及步骤.
环境配置
引入Word API-Free Spire.Doc for .NET( Spire.Doc.dll)
1. 通过 NuGet引入dll(2种方法)的方法
(1)可以在Visual Studio中打开“解决方案资源管理器”,鼠标右键点击“引用”,“管理NuGet包”,然后搜索“Free Spire.Doc”,点击“安装”.等待程序安装完成.
(2)将以下内容复制到PM控制台安装:
2. 手动添加dll引用的方法
可通过手动 下载包到本地,然后解压,找到BIN文件夹下的Spire.Doc.dll.然后在Visual Studio中打开“解决方案资源管理器”,鼠标右键点击“引用”,“添加引用”,将本地路径BIN文件夹下的dll文件添加引用至程序.
Add multi-line and multi-column image watermark
Realize multi-row and multi-column image watermark effect,That is, add a picture to the header,And simulate the effect of spreading the watermark all over the page by duplicating the picture multiple times,Depending on the number of different pictures copied horizontally or vertically,The distribution effect of the watermark image on the page can be adjusted arbitrarily.以下,This is the main code step for implementing image watermarking:
- 创建Document类的对象,并通过Document.LoadFromFile(string fileName)方法加载Word文档.
- forLoop through all in the documentSection,并通过Document.Sections[int Index]Property gets the section in the page.
- 使用HeadersFooters.Header属性获取页眉,并通过HeaderFooter.AddParagraph()方法添加段落到页眉.
- 创建DocPicture类的对象,并调用DocPicture.LoadImage(string imgFile)method to load the watermarked image,以及通过TextWrappingStyleThe enumeration value sets the image wrapping method.
- 通过for循环以DocPicture.Clone()The method duplicates the image multiple times,并通过DocPicture.VerticalPosition和DocPicture.HorizontalPositionThe property sets the picture position arrangement.
- 调用Paragraph.ChildObjects.Add(IDocumentObject entity)method to add an image to the header paragraph.
- 最后,通过Document.SaveToFile(string fileName, FileFormat fileFormat)The methods to save the document all specify the path.
C#
VB.NET
—END—
边栏推荐
- The realization of the list
- 如何选择一块真正“好用的、性能高”的远程控制软件
- R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化堆叠的柱状图(stacked bar plot)、lab.pos参数指定柱状图的数值标签的位置,lab.col参数指定数值标
- The R language uses the ggtexttable function of the ggpubr package to visualize the table data (draw the table directly or add the table data to the image), set the theme parameter to customize the fi
- R语言ggpubr包的ggline函数可视化分组折线图、add参数为mean_se和dotplot可视化不同水平均值的折线图并为折线图添加误差线(se标准误差)和点阵图、自定义palette设置颜色
- 软件工程国考总结——选择题
- Geoffery Hinton:深度学习的下一个大事件
- MSYS2 QtCreator Clangd 代码分析找不到 mm_malloc.h的问题补救
- LayaBox---TypeScript---迭代器和生成器
- Why use BGP?
猜你喜欢
Shell script realizes multi-select DNS simultaneous batch resolution of domain name IP addresses (new update)
Linux system uninstall, install, upgrade, migrate clickHouse database
You Only Hypothesize Once: 用旋转等变描述子估计变换做点云配准(已开源)
小几届的学弟问我,软件测试岗是选11k的华为还是20k的小公司,我直呼受不了,太凡尔赛了~
详细总结SoC、DSP、MCU、GPU和FPGA等基础概念
软件工程国考总结——选择题
WPF 截图控件之文字(七)「仿微信」
你认同这个观点吗?大多数企业的数字化都只是为了缓解焦虑
yolov7创新点
阿里CTO程立:阿里巴巴开源的历程、理念和实践
随机推荐
R语言ggpubr包的ggline函数可视化分组折线图、add参数为mean_se和dotplot可视化不同水平均值的折线图并为折线图添加误差线(se标准误差)和点阵图、自定义palette设置颜色
为什么要使用BGP?
One Summer of Open Source | How to Quickly Integrate Log Modules in GO Language Framework
外包学生管理系统架构文档
R语言时间序列数据的平滑:使用KernSmooth包的dpill函数和locpoly函数对时间序列数据进行平滑以消除噪声
21年毕业转行软件测试,从0收入到月薪过万,我真的很幸运...
循环结构--do-while循环
Verilog's random number system task----$random
8年软件测试工程师的感悟:与薪资相匹配的永远是实力
LayaBox---TypeScript---Module
情景剧《重走长征路》上演
牛客刷题——剑指offer(第三期)
LayaBox---TypeScript---JSX
LayaBox---TypeScript---JSX
R language ggplot2 visualization: use the ggtexttable function of the ggpubr package to visualize tabular data (directly draw tabular graphs or add tabular data to images), use tbody_add_border to add
博云入选Gartner中国DevOps代表厂商
R语言ggplot2可视化:基于aes函数中的fill参数和shape参数自定义绘制分组折线图并添加数据点(散点)、使用theme函数的legend.position函数配置图例到图像右侧
After 21 years of graduation, I switched to software testing. From 0 income to a monthly salary of over 10,000, I am really lucky...
MSYS2 QtCreator Clangd 代码分析找不到 mm_malloc.h的问题补救
Smoothing of time series data in R language: smoothing time series data to remove noise using the dpill function and locpoly function of the KernSmooth package