日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

c# pdf转html,C# 将PDF转为Word、Html、XPS、SVG、PCL、PS——基于Spire.Cloud.PDF

發布時間:2023/12/31 C# 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c# pdf转html,C# 将PDF转为Word、Html、XPS、SVG、PCL、PS——基于Spire.Cloud.PDF 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Spire.Cloud.PDF提供了接口PdfConvertApi可用于將PDF文檔轉換為其他格式文檔,如Word(docx/doc)、Html、XPS、SVG、PCL、PS、Png以及XPS轉成PDF。本文將選取其中幾種格式為例,介紹具體轉換方法。

必要步驟:

步驟一:dll文件獲取及導入。

方法1

.

通過官網

文件包。(須注冊并登錄)

下載后,解壓文件,并將Spire.Cloud.Pdf.Sdk.dll

文件及其他三個

dll

添加引用至

VS

程序

方法2.

在程序中通

,直接導入所有

dll

導入效果如下如所示:

步驟二:

App ID及Key獲取。在

創建賬號,并在“我的應用”板塊中創建應用以獲得App ID及App Key。

步驟三:源文檔上傳。在“文檔管理”板塊,上傳源文檔。這里可以建文件夾,將文檔存放在文件夾下。不建文件夾時,源文檔及結果文檔直接保存在根目錄。本文示例中,建了兩個文件夾,分別用于存放源文檔及結果文檔。(云平臺提供免費1 萬次調用次數和 2G 文檔內存)

C# 代碼示例

【示例1】PDF 轉Word(docx/doc)

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

using?System.IO;

namespace?PDFToWord

{

class?PDFToDocx

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConverterApi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToDocx.docx";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?destFilePath2?=?"pdfconversion/PDFToDoc.doc";

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉為Word文檔格式

pdfConverterApi.ConvertPdfInStorageToDocx(name,?destFilePath,?folder,?password);

pdfConverterApi.ConvertPdfInStorageToDoc(name,?destFilePath2,?folder,?password);

}

}

}

【示例2】PDF轉Html

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

namespace?PDFToHTML

{

class?Program

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConvertApi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToHtml.html";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉換為HTML格式

pdfConvertApi.ConvertPdfInStorageToHtml(name,destFilePath,folder,password);

}

}

}

【示例3】PDF轉XPS

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

namespace?PDFToXPS

{

class?Program

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConvertapi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToXPS.xps";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉為XPS

pdfConvertapi.ConvertPdfInStorageToXps(name,?destFilePath,?folder,?password);

}

}

}

【示例4】PDF轉SVG

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

namespace?PDFToSvg

{

class?Program

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConvertapi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToSvg.svg";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉為SVG

pdfConvertapi.ConvertPdfInStorageToSvg(name,?destFilePath,?folder,?password);

}

}

}

注:這里轉為svg是將原PDF文檔中的每一頁單獨轉換為一個svg文檔,如果原PDF文檔包含多頁,轉換后默認生成一個文件夾,將生成的每一頁svg放在這個文件夾下。

【示例5】PDF轉PCL

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

namespace?PDFToPcl

{

class?Program

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConvertApi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToPcl.pcl";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉換為Pcl格式

pdfConvertApi.ConvertPdfInStorageToPcl(name,?destFilePath,?folder,?password);

}

}

}

【示例6】PDF轉PS

using?System;

using?Spire.Cloud.Pdf.Sdk.Client;

using?Spire.Cloud.Pdf.Sdk.Api;

namespace?PDFToPs

{

class?Program

{

static?String?appId?=?"App?ID";

static?String?appKey?=?"App?Key";

static?void?Main(string[]?args)

{

//配置賬號信息

Configuration?pdfConfiguration?=?new?Configuration(appId,?appKey);

PdfConvertApi?pdfConvertapi?=?new?PdfConvertApi(pdfConfiguration);

string?name?=?"sample.pdf";//源文檔

string?folder?=?"input";//設置源文檔所在文件夾(如果源文檔在根目錄下,不在文件夾中,可設置為null)

string?destFilePath?=?"pdfconversion/PDFToPs.ps";//設置轉換后的目標文檔路徑(文檔放置在pdfconversion文件夾下)

string?password?=?null;//設置文檔密碼(如果文檔沒有密碼則設置成null)

//調用方法轉為PS

pdfConvertapi.ConvertPdfInStorageToPs(name,?destFilePath,?folder,?password);

}

}

}

文檔格式轉換效果:

(本文完)

總結

以上是生活随笔為你收集整理的c# pdf转html,C# 将PDF转为Word、Html、XPS、SVG、PCL、PS——基于Spire.Cloud.PDF的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。