文档半岛外围网上直营>>Spire.PDF教程>>Spire.PDF功能演示:在c#中从URL下载PDF文档
Spire.PDF功能演示:在c#中从URL下载PDF文档
Spire.PDF是一个专业的PDF组件,能够独立地创建、编写、编辑、操作和阅读PDF文件,支持 .NET、Java、WPF和Silverlight。Spire.PDF的PDF API拥有丰富的功能,如安全设置(包括数字签名)、PDF文本/附件/图片提取、PDF文件合并/拆分、元数据更新、章节和段落优化、图形/图像描绘和插入、表格创建和处理、数据导入等等。
本文介绍如何使用带有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("//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.IO
Imports System.Net
Imports Spire.Pdf
Namespace 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 Class
End Namespace
运行项目后结果:
慧都是E-iceblue官方友好合作伙伴,如果您对spire.PDF感兴趣,可以了解具体授权价格和使用机制。

QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线