没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2020-03-17 10:24:53.307|阅读 373 次
概述:在本系列教程中,将为开发者带来Aspose.PDF for .NET的一系列使用教程,例如进行文档间的转换,如何标记PDF文件,如何使用表单和图表等等。本文将介绍创建,更新和提取链接。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Aspose.PDF for .NET是一种高PDF处理和解析API,用于在跨平台应用程序中执行文档管理和操作任务。API可以轻松用于生成、修改、转换、渲染、保护和打印PDF文档,而无需使用Adobe Acrobat。此外,API还提供PDF压缩选项,表格创建和操作,图形和图像功能,广泛的超链接功能,印章和水印任务,扩展的安全控制和自定义字体处理。
在接下来的系列教程中,将为开发者带来Aspose.PDF for .NET的一系列使用教程,例如进行文档间的转换,如何标记PDF文件,如何使用表单和图表等等。本文将介绍创建,更新和提取链接。
>>Aspose.PDF for .NET更新至最新版v20.3,欢迎下载体验。
通过将到应用程序的链接添加到文档中,可以从文档链接到应用程序。例如,当希望读者在教程中的特定位置采取特定措施或创建功能丰富的文档时,此功能很有用。要创建一个应用程序链接:
以下代码段显示了如何在PDF文件中创建到应用程序的链接。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Open document Document document = new Document( dataDir + "CreateApplicationLink.pdf"); // Create link Page page = document.Pages[1]; LinkAnnotation link = new LinkAnnotation(page, new Aspose.Pdf.Rectangle(100, 100, 300, 300)); link.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); link.Action = new LaunchAction(document, dataDir + "CreateApplicationLink.pdf"); page.Annotations.Add(link); dataDir = dataDir + "CreateApplicationLink_out.pdf"; // Save updated document document.Save(dataDir);
.NET的Aspose.PDF允许您添加到外部PDF文件的链接,以便可以将多个文档链接在一起。要创建PDF文档链接:
以下代码段显示了如何在PDF文件中创建PDF文档链接。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Open document Document document = new Document(dataDir+ "CreateDocumentLink.pdf"); // Create link Page page = document.Pages[1]; LinkAnnotation link = new LinkAnnotation(page, new Aspose.Pdf.Rectangle(100, 100, 300, 300)); link.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); link.Action = new GoToRemoteAction(dataDir + "RemoveOpenAction.pdf", 1); page.Annotations.Add(link); dataDir = dataDir + "CreateDocumentLink_out.pdf"; // Save updated document document.Save(dataDir);
如在PDF文件中添加超链接中所讨论的,LinkAnnotation该类使得可以在PDF文件中添加链接。还有一个类似的类,用于从PDF文件内部获取现有链接。如果需要更新现有链接,请使用此选项。要更新现有链接:
将链接目标设置为同一文档中的页面
以下代码段显示了如何更新PDF文件中的链接并将其目标设置为文档的第二页。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document doc = new Document(dataDir + "UpdateLinks.pdf"); // Get the first link annotation from first page of document LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1]; // Modification link: change link destination GoToAction goToAction = (GoToAction)linkAnnot.Action; // Specify the destination for link object // The first parameter is document object, second is destination page number. // The 5ht argument is zoom factor when displaying the respective page. When using 2, the page will be displayed in 200% zoom goToAction.Destination = new Aspose.Pdf.Annotations.XYZExplicitDestination(1, 1, 2, 2); dataDir = dataDir + "PDFLINK_Modified_UpdateLinks_out.pdf"; // Save the document with updated link doc.Save(dataDir);
将链接目标设置为网址
要更新超链接使其指向网址,请实例化该GoToURIAction对象并将其传递给LinkAnnotation的Action属性。以下代码段显示了如何更新PDF文件中的链接并将其目标设置为网址。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document doc = new Document(dataDir + "UpdateLinks.pdf"); // Get the first link annotation from first page of document LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1]; // Modification link: change link action and set target as web address linkAnnot.Action = new GoToURIAction("www.aspose.com"); dataDir = dataDir + "SetDestinationLink_out.pdf"; // Save the document with updated link doc.Save(dataDir);
将链接目标设置为另一个PDF文件
以下代码段显示了如何更新PDF文件中的链接并将其目标设置为另一个PDF文件。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document document = new Document(dataDir + "UpdateLinks.pdf"); LinkAnnotation linkAnnot = (LinkAnnotation)document.Pages[1].Annotations[1]; GoToRemoteAction goToR = (GoToRemoteAction)linkAnnot.Action; // Next line update destination, do not update file goToR.Destination = new XYZExplicitDestination(2, 0, 0, 1.5); // Next line update file goToR.File = new FileSpecification(dataDir + "input.pdf"); dataDir = dataDir + "SetTargetLink_out.pdf"; // Save the document with updated link document.Save(dataDir);
更新LinkAnnotation文本颜色
链接注释不包含文本。而是将文本放置在页面内容的注释下。因此,要更改文本的颜色,请替换页面文本的颜色,而不要尝试更改批注的颜色。以下代码段显示了如何更新PDF文件中链接注释的颜色。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document doc = new Document(dataDir + "UpdateLinks.pdf"); foreach (Annotation annotation in doc.Pages[1].Annotations) { if (annotation is LinkAnnotation) { // Search the text under the annotation TextFragmentAbsorber ta = new TextFragmentAbsorber(); Rectangle rect = annotation.Rect; rect.LLX -= 10; rect.LLY -= 10; rect.URX += 10; rect.URY += 10; ta.TextSearchOptions = new TextSearchOptions(rect); ta.Visit(doc.Pages[1]); // Change color of the text. foreach (TextFragment tf in ta.TextFragments) { tf.TextState.ForegroundColor = Color.Red; } } } dataDir = dataDir + "UpdateLinkTextColor_out.pdf"; // Save the document with updated link doc.Save(dataDir);
链接在PDF文件中表示为注释,因此要提取链接,请提取所有LinkAnnotation对象。
以下代码段显示了如何从PDF文件提取链接。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Open document Document document = new Document(dataDir+ "ExtractLinks.pdf"); // Extract actions Page page = document.Pages[1]; AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial)); page.Accept(selector); IListlist = selector.Selected; Annotation annotation = (Annotation)list[0]; dataDir = dataDir + "ExtractLinks_out.pdf"; // Save updated document document.Save(dataDir);还想要更多吗?您可以点击阅读【2019 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(642018183),我们很高兴为您提供查询和咨询。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
本文档包含了有关安装和使用DevExpress ASP.NET Web Forms v25.1版本控件的开发要求信息。
当您需要更改页面尺寸或优化不同设备的布局时,调整PDF大小会很有帮助。在本教程中,您将学习如何使用 C#、Java 和 Python 以编程方式调整 PDF 文档页面大小。
在 C# 中将 DataTable 导出为 Excel 文件,是 .NET 开发中常见的任务,广泛应用于报表生成、日志导出、系统间数据共享等场景。本文将介绍如何使用 Spire.XLS for .NET 将 DataTable 导出为 Excel(.xlsx/.xls)文件,包含数据创建、导出保存、格式设置等实用步骤。
本文主要介绍DevExpress WPF Grid控件中网格视图数据布局中的紧凑模式,欢迎下载最新版组件体验!
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号