没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|行业资讯|编辑:胡涛|2024-09-13 15:40:32.263|阅读 93 次
概述:在本文中,您将学习如何使用Spire.PDF for .NET以编程方式设置 PDF 的背景颜色或图像。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
在 PDF 文档中,背景是指页面内容背后的整体视觉外观。背景可以是简单的纯色,也可以是您选择的图像。向 PDF 添加背景可以帮助您增加文档的视觉趣味,并提高可读性。在本文中,您将学习如何使用Spire.PDF for .NET以编程方式设置 PDF 的背景颜色或图像。
Spire.PDF for .NET 是一款独立 PDF 控件,用于 .NET 程序中创建、编辑和操作 PDF 文档。使用 Spire.PDF 类库,开发人员可以新建一个 PDF 文档或者对现有的 PDF 文档进行处理,且无需安装 Adobe Acrobat。
E-iceblue 功能类库Spire 系列文档处理组件均由中国本土团队研发,不依赖第三方软件,不受其他国家的技术或法律法规限制,同时适配国产操作系统如中科方德、中标麒麟等,兼容国产文档处理软件 WPS(如 .wps/.et/.dps 等格式
首先,您需要将 Spire.PDF for.NET 包中包含的 DLL 文件作为引用添加到您的 .NET 项目中。 可以从此链接下载 DLL 文件,也可以通过NuGet安装。
PM> Install-Package Spire.PDF
Spire.PDF for .NET 提供的PdfPageBase.BackgroundColor属性允许您将纯色设置为 PDF 背景。以下是详细步骤。
【C# 】
using Spire.Pdf;
using System.Drawing;
namespace PDFBackgroundColor
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();
//Load a sample PDF file from disk
pdf.LoadFromFile("input.pdf");
//Loop through the pages in the PDF file
foreach (PdfPageBase page in pdf.Pages)
{
//Set the background color for each page
page.BackgroundColor = Color.Yellow;
//Set the opacity of the background
page.BackgroudOpacity = 0.1f;
}
//Save the result PDF file
pdf.SaveToFile("BackgroundColor.pdf");
pdf.Close();
}
}
}
【VB.NET 】
Imports Spire.PDF
Imports System.Drawing
Namespace PDFBackgroundColor
Class Program
Private Shared Sub Main(ByVal args() As String)
'Create a PdfDocument instance
Dim pdf As PdfDocument = New PdfDocument
'Load a sample PDF file from disk
pdf.LoadFromFile("input.pdf")
'Loop through the pages in the PDF file
For Each page As PdfPageBase In pdf.Pages
'Set the background color for each page
page.BackgroundColor = Color.Yellow
'Set the opacity of the background
page.BackgroudOpacity = 0.1!
Next
'Save the result PDF file
pdf.SaveToFile("BackgroundColor.pdf")
pdf.Close()
End Sub
End Class
End Namespace
如果要添加图像作为背景以匹配文档主题,可以使用PdfPageBase.BackgroundImage属性。以下是详细步骤。
【C# 】
using Spire.Pdf;
using System.Drawing;
namespace PDFBackgroundColor
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();
//Load a sample PDF file from disk
pdf.LoadFromFile("input.pdf");
//Loop through the pages in the PDF file
foreach (PdfPageBase page in pdf.Pages)
{
//Set the background color for each page
page.BackgroundColor = Color.Yellow;
//Set the opacity of the background
page.BackgroudOpacity = 0.1f;
}
//Save the result PDF file
pdf.SaveToFile("BackgroundColor.pdf");
pdf.Close();
}
}
}
【VB.NET 】
Imports Spire.PDF
Imports System.Drawing
Namespace PDFBackgroundColor
Class Program
Private Shared Sub Main(ByVal args() As String)
'Create a PdfDocument instance
Dim pdf As PdfDocument = New PdfDocument
'Load a sample PDF file from disk
pdf.LoadFromFile("input.pdf")
'Loop through the pages in the PDF file
For Each page As PdfPageBase In pdf.Pages
'Set the background color for each page
page.BackgroundColor = Color.Yellow
'Set the opacity of the background
page.BackgroudOpacity = 0.1!
Next
'Save the result PDF file
pdf.SaveToFile("BackgroundColor.pdf")
pdf.Close()
End Sub
End Class
End Namespace
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询 ;技术交流Q群(767755948)
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




Tech Soft 3D的HOOPS Exchange与HOOPS Access,还是Spatial的3D InterOp,它们都体现了当前工程软件领域在数据互操作技术上的发展趋势—— 即以 高精度几何解析、跨平台开放架构与可持续兼容性 为核心,构建从设计、仿真到制造的数字数据链。
在现代复杂系统开发过程中,需求管理是确保项目成功的关键环节。Sparx Systems公司的Enterprise Architect作为一款先进的UML建模和设计工具,其需求管理模块通过完整的追溯机制,为项目提供了从需求收集到设计实现、测试验证的全生命周期可追溯性解决方案,有效保障了项目交付质量与规范符合度。
在企业应用、报表系统或财务工具的开发中,生成规范、专业的 PDF 文档是常见需求。与其在代码中硬编码布局,不如使用模板来提高开发效率。模板不仅能加快开发进程,还能确保品牌视觉与文档格式的一致性。本文将介绍如何使用 Spire.PDF for .NET 在 C# 中通过 HTML 模板 或 预设 PDF 模板 生成 PDF 文档,无论是需要动态布局还是快速替换占位符,都能灵活应对。
近日,全球知名的文档与图像处理组件Aspose正式推出 25.10 版本!本次更新覆盖 Words、Cells、PDF、Imaging、CAD、PSD、OCR 等多条产品线,重点聚焦性能提升、格式兼容性优化以及跨语言平台的统一支持,为开发者提供更高效、更稳定的企业级文档处理体验。
相关产品
Spire.PDF for .NET是独立的PDF控件,用于.NET程序中创建、编辑和操作PDF文档
Spire.PDF for WPFSpire.PDF for WPF 是一款让你的app能够读取、写入和操作PDF文档的完全独立的组件,不需要任何第三方组件库。
最新文章 MORE
半岛外围网上直营相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营