C# 设置PDF页面缩放比例

 时间:2024-10-14 12:45:56

此经验将分享通过C#编程来设置PDF页面缩放比例的方法。

工具/原料

Free Spire.PDF for .NET(免费版)

dll引用

1、通过官网(https://www.e-iceblue.cn/Introduce/Free-Spire-PDF-NET.html)下载安装包--解压-安装。在程序中添加引用Spire.Pdf.dll,dll文件在安装路径下的bin文件夹中。2.通过Nuget官网下载。(http://www.nuget.org/packages/FreeSpire.PDF/)添加引用完成后,如下图:

C# 设置PDF页面缩放比例

C#代码示例

1、using Spire.Pdf;using Spire.Pdf.Actions;using Spire.Pdf.General;using System.Drawing稆糨孝汶;namespace SetZoomFactor_PDF{ class Program { static void Main(string[] args) { //新建PDFDocument示例并加载PDF Sample文档 PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("sample.pdf"); //获取PDF文档第一页 PdfPageBase page = pdf.Pages[0]; //新建一个PdfDestination对象,该对象包含两个参数,页面及页面显示位置 PdfDestination dest = new PdfDestination(page, new PointF(-60f, -60f)); //设置缩放属性的值 dest.Zoom = 1.5f; //设置打开PDF文档时的页面显示缩放比例 PdfGoToAction gotoaction = new PdfGoToAction(dest); pdf.AfterOpenAction = gotoaction; //保存文档 pdf.SaveToFile("result.pdf", FileFormat.PDF); System.Diagnostics.Process.Start("result.pdf"); } }}

2、页面缩放比例设置结果:

C# 设置PDF页面缩放比例
  • FastStone Capture录制屏幕
  • 在WPS中插入漂亮美观的艺术字
  • bim的详细介绍
  • MORNSUN LD10系列模块电源说明书
  • 图示EXCEL表格vba系列59之vbDefaultButton4简介
  • 热门搜索
    膜法传奇加盟怎么样 ipad已停用怎么办 呼吸困难胸闷气短是怎么回事 大学培养方式怎么填 双眼皮胶水怎么用 婴儿感冒鼻塞怎么办 孩子不听话家长怎么办 怎么让头发长的快 水肿是怎么回事 胃火大口臭怎么办