当前位置:网站首页>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—
边栏推荐
- 零代码工具推荐---HiFlow
- 如何封装微信小程序的 wx.request() 请求
- DirectX修复工具增强版「建议收藏」
- 3 d laser slam: LeGO - LOAM - ground point extracting method and the analysis of the code
- 从零开始Blazor Server(5)--权限验证
- How to choose a truly "easy-to-use, high-performance" remote control software
- 为什么要使用BGP?
- 情景剧《重走长征路》上演
- MySQL百万数据优化总结 一
- MSYS2 QtCreator Clangd code analysis can not find mm_malloc.h problem remedy
猜你喜欢
随机推荐
牛客刷题——剑指offer(第三期)
org.apache.ibatis.binding.BindingException Invalidbound statement (not found)的解决方案和造成原因分析(超详细)
突破边界,华为存储的破壁之旅
List-based queuing and calling system
如何安装dosbox(pycharm详细安装教程)
8年软件测试工程师的感悟:与薪资相匹配的永远是实力
The ggline function of the R language ggpubr package visualizes grouped line graphs, the add parameter is mean_se and dotplot to visualize line graphs of different level averages, and adds error bars
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
有奖征集|TaoCloud&宝德联合举办全闪POC!
npm ERR! 400 Bad Request - PUT xxx - Cannot publish over previously published version “1.0.0“.
R语言时间序列数据算术运算:使用log函数将时间序列数据的数值对数化、使用diff函数计算对数化后的时间序列数据的逐次差分(计算价格的对数差分)
Jay Chou's new song is released, crawl the "Mojito" MV barrage, and see what the fans have to say!
LayaBox---TypeScript---Module
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
leetcode: 200. 岛屿数量
行为型模式-模板方法模式
详细总结SoC、DSP、MCU、GPU和FPGA等基础概念
字节跳动软件测试岗,收到offer后我却拒绝了~给面试的人一些忠告....
games202:三,实时环境光照IBL + PRT
sqlmap安装教程用w+r打开(sqlyog安装步骤)









