没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|行业资讯|编辑:胡涛|2024-09-29 13:51:11.743|阅读 8 次
概述:在本文中,我们将演示如何使用Spire.PDF for .NET在 C# 和 VB.NET 中为 PDF 文档设置查看器首选项和缩放因子。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
优化查看器首选项和缩放因子对于改善 PDF 文档的查看体验至关重要。通过使用适当的查看器首选项和缩放因子,您可以使您的 PDF 文档更加用户友好、可查看且适合不同的设备和平台。在本文中,我们将演示如何使用Spire.PDF for .NET在 C# 和 VB.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
查看器首选项是可应用于 PDF 文档的设置,用于控制在 PDF 查看器中打开时文档的显示方式。这些首选项会影响查看体验的各个方面,例如初始视图、页面布局和导航选项卡。
要使用 Spire.PDF for .NET 设置 PDF 文档的查看器首选项,您可以按照以下步骤操作:
【C# 】
using Spire.Pdf; namespace SetViewerPreference { internal class Program { static void Main(string[] args) { //Initialize an instance of PdfDocument class PdfDocument pdf = new PdfDocument(); //Load a PDF document pdf.LoadFromFile(@"Example.pdf"); //Get the PdfViewerPreferences object PdfViewerPreferences viewerPreferences = pdf.ViewerPreferences; //Set viewer preference viewerPreferences.FitWindow = false; viewerPreferences.HideMenubar = true; viewerPreferences.HideToolbar = true; viewerPreferences.CenterWindow= true; viewerPreferences.DisplayTitle = false; viewerPreferences.PageLayout = PdfPageLayout.SinglePage; viewerPreferences.PageMode = PdfPageMode.UseNone; //Save the result document pdf.SaveToFile("SetViewerPreference.pdf"); pdf.Close(); } } }
【VB.NET 】
Imports Spire.Pdf Namespace SetViewerPreference Friend Class Program Private Shared Sub Main(ByVal args As String()) 'Initialize an instance of PdfDocument class Dim pdf As PdfDocument = New PdfDocument() 'Load a PDF document pdf.LoadFromFile("Example.pdf") 'Get the PdfViewerPreferences object Dim viewerPreferences As PdfViewerPreferences = pdf.ViewerPreferences 'Set viewer preference viewerPreferences.FitWindow = False viewerPreferences.HideMenubar = True viewerPreferences.HideToolbar = True viewerPreferences.CenterWindow = True viewerPreferences.DisplayTitle = False viewerPreferences.PageLayout = PdfPageLayout.SinglePage viewerPreferences.PageMode = PdfPageMode.UseNone 'Save the result document pdf.SaveToFile("SetViewerPreference.pdf") pdf.Close() End Sub End Class End Namespace
缩放系数决定了 PDF 文档打开时的缩放级别。默认情况下,大多数 PDF 查看器将缩放系数设置为“适合页面”,即缩放文档以适合查看器窗口的宽度。但是,您也可以根据需要设置特定的缩放系数,例如 60%、150% 或 200%。
要使用 Spire.PDF for .NET 设置 PDF 文档的缩放比例,您可以按照以下步骤操作:
【C# 】
using Spire.Pdf; using Spire.Pdf.Actions; using Spire.Pdf.General; using System.Drawing; namespace SetZoomFactor { internal class Program { static void Main(string[] args) { //Initialize an instance of the PdfDocument class PdfDocument pdf = new PdfDocument(); //Load a PDF document pdf.LoadFromFile(@"Example.pdf"); //Get the first page PdfPageBase page = pdf.Pages[0]; //Initialize an instance of the PdfDestination class PdfDestination dest = new PdfDestination(page); //Set the destination mode dest.Mode = PdfDestinationMode.Location; //Set the destination location dest.Location = new PointF(40f, 40f); //Set the zoom factor dest.Zoom = 1.5f; //Initialize an instance of the PdfGoToAction class PdfGoToAction gotoAction = new PdfGoToAction(dest); //Set the action to be executed when the document is opened pdf.AfterOpenAction = gotoAction; //Save the result document pdf.SaveToFile("SetZoomFactor.pdf"); pdf.Close(); } } }
【VB.NET 】
Imports Spire.Pdf Imports Spire.Pdf.Actions Imports Spire.Pdf.General Imports System.Drawing Namespace SetZoomFactor Friend Class Program Private Shared Sub Main(ByVal args As String()) 'Initialize an instance of the PdfDocument class Dim pdf As PdfDocument = New PdfDocument() 'Load a PDF document pdf.LoadFromFile("Example.pdf") 'Get the first page Dim page As PdfPageBase = pdf.Pages(0) 'Initialize an instance of the PdfDestination class Dim dest As PdfDestination = New PdfDestination(page) 'Set the destination mode dest.Mode = PdfDestinationMode.Location 'Set the destination location dest.Location = New PointF(40F, 40F) 'Set the zoom factor dest.Zoom = 1.5F 'Initialize an instance of the PdfGoToAction class Dim gotoAction As PdfGoToAction = New PdfGoToAction(dest) 'Set the action to be executed when the document is opened pdf.AfterOpenAction = gotoAction 'Save the result document pdf.SaveToFile("SetZoomFactor.pdf") pdf.Close() End Sub End Class End Namespace
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询 ;技术交流Q群(767755948)
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
通过本次更新,HOOPS Exchange不仅强化了对各类主流文件格式的支持,增强了跨平台的兼容性和稳定性,还为用户提供了更便捷、更高效的功能体验,进一步巩固了其在3D数据转换和交换领域的领先地位。
在工业和建筑领域,CAD 文件的处理至关重要。CADViewX 作为一款功能强大的 ActiveX 组件,能够为应用程序注入高效的 CAD 处理能力,助力企业和开发者轻松应对各类 CAD 文件操作需求。
在现代 Web 应用开发领域,Syncfusion 公司的 Essential Studio for JavaScript 脱颖而出,成为开发者构建高效、美观应用的得力助手。它不仅提供了丰富的 UI 组件库,还深度融合了性能优化与跨平台支持,帮助企业快速实现复杂业务需求。以下从功能特点、核心优势和应用场景三方面展开,带您全面了解这一工具。
工业3D应用开发,既要建模好、也要可视化强,选对技术栈非常关键。希望这篇对比能帮你理清选型方向,少踩坑、快上线!
Spire.PDF for .NET是独立的PDF控件,用于.NET程序中创建、编辑和操作PDF文档
Spire.Office for .NET专业的.NET Office套件,涵盖office文档创建、编辑、转换、管理和OCR内容识别等操作
Spire.Doc for .NETSpire.Doc for .NET 是一款专门对 Word 文档进行操作的 .NET 类库。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢