本文介绍如何使用带有C#和VB.NET的Spire.PDF从URL下载PDF文档。
Spire.PDF是一个专业的PDF组件,能够独立地创建、编写、编辑、操作和阅读PDF文件,支持 .NET、Java、WPF和Silverlight。Spire.PDF的PDF API拥有丰富的功能,如安全设置(包括数字签名)、PDF文本/附件/图片提取、PDF文件合并/拆分、元数据更新、章节和段落优化、图形/图像描绘和插入、表格创建和处理、数据导入等等。
>>Spire.PDF更新至最新版v7.5,欢迎下载体验
本文介绍如何使用带有C#和VB.NET的Spire.PDF从URL下载PDF文档。
C#
using System.IO;using System.Net;using Spire.Pdf;namespace DownloadPdfFromUrl{ class Program { static void Main(string[] args) { //Create a PdfDocument object PdfDocument doc = new PdfDocument(); //Create a WebClient object WebClient webClient = new WebClient(); //Download data from URL and save as memory stream using (MemoryStream ms = new MemoryStream(webClient.DownloadData("http://www.e-iceblue.com/images/sample.pdf"))) { //Load the stream doc.LoadFromStream(ms); } //Save to PDF file doc.SaveToFile("result.pdf", FileFormat.PDF); } }}
VB.NET
Imports System.IOImports System.NetImports Spire.PdfNamespace DownloadPdfFromUrl Class Program Shared Sub Main(ByVal args() As String) 'Create a PdfDocument object Dim doc As PdfDocument = New PdfDocument() 'Create a WebClient object Dim webClient As WebClient = New WebClient() 'Download data from URL and save as memory stream Imports(MemoryStream ms = New MemoryStream(webClient.DownloadData("http:'www.e-iceblue.com/images/sample.pdf"))) { 'Load the stream doc.LoadFromStream(ms) } 'Save to PDF file doc.SaveToFile("result.pdf", FileFormat.PDF) End Sub End ClassEnd Namespace
运行项目后结果:
是E-iceblue官方友好合作伙伴,如果您对spire.PDF感兴趣,可以联系在线客服了解具体授权价格和使用机制。
标签:
来源:慧都
声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!