条件:需要引用Spire.pdf 包。再使用以下类库进行具体操作。如果没有的表况下。可以到这里下载https://download.csdn.net/download/wulixing/11227168
也可以查询(征信PDF分析自动生成TXT并入Sqlserver库源码.rar) 这里是我写的一个案例。有相当不错的源码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Spire.Pdf;
using System.Threading;
using System.Drawing;
using System.Drawing.Imaging;
namespace PDFServer
{
public class PDFHelper
{
/// <summary>
/// 打開一個網絡地址,并且保存為一個PDF
/// </summary>
/// <param name="webUrl">網絡地址</param>
/// <param name="fileaddress">保存的物理地址</param>
/// <param name="filename">保存的PDF名稱</param>
/// <returns></returns>
public string PdfReader(string webUrl,string fileaddress, string filename)
{
String pdoc = "";
//create PdfDocument instance
PdfDocument doc = new PdfDocument();
//load html from URL
var thread = new Thread(() =>
{
doc.LoadFromHTML(webUrl, false, true, true);
});
//set to single thread
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//save to PDF document
String s = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
doc.SaveToFile(fileaddress + s + filename, FileFormat.PDF);//XXX.PDF\ HTML\ DOC\ XPS
doc.Close();
System.Diagnostics.Process.Start(fileaddress+s + filename);
return pdoc;
}
/// <summary>
/// 打開PDF文件
/// </summary>
/// <param name="filename">物理路徑 H:\pdfceshi\陈军清个人信用报告.pdf</param>
/// <param name="txtpath">數據讀取后保存的txt文件 物理路徑 H:\pdfceshi\</param>
/// <pa