aspose pdf 水印
时间: 2023-10-06 08:07:53 浏览: 69
Aspose.PDF是一款功能强大的PDF处理API,可以用于在跨平台应用程序中生成、修改、转换、呈现、保护和打印PDF文档。该API还提供了添加水印的功能。您可以使用Aspose.PDF在PDF文档的指定位置添加文本或图像水印。以下是一个示例代码,演示如何在PDF文档中添加文本水印:
C#代码示例:
```
// 打开文档
Document pdfDocument = new Document("input.pdf");
// 创建一个文本水印对象
TextStamp textStamp = new TextStamp("Watermark Text");
textStamp.Background = true;
textStamp.XIndent = 100;
textStamp.YIndent = 100;
textStamp.RotateAngle = 45.0;
textStamp.TextState.FontSize = 24;
textStamp.TextState.FontStyle = FontStyles.Bold;
textStamp.TextState.ForegroundColor = Color.Red;
// 添加水印到每个页面
foreach (Page page in pdfDocument.Pages)
{
page.AddStamp(textStamp);
}
// 保存输出文档
pdfDocument.Save("output.pdf");
```
VB.NET代码示例:
```
' 打开文档
Dim pdfDocument As New Document("input.pdf")
' 创建一个文本水印对象
Dim textStamp As New TextStamp("Watermark Text")
textStamp.Background = True
textStamp.XIndent = 100
textStamp.YIndent = 100
textStamp.RotateAngle = 45.0
textStamp.TextState.FontSize = 24
textStamp.TextState.FontStyle = FontStyles.Bold
textStamp.TextState.ForegroundColor = Color.Red
' 添加水印到每个页面
For Each page As Page In pdfDocument.Pages
page.AddStamp(textStamp)
Next
' 保存输出文档
pdfDocument.Save("output.pdf")
```
相关推荐
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)