翻譯|行業(yè)資訊|編輯:胡濤|2024-08-21 10:10:20.833|閱讀 134 次
概述:在本文中,您將學(xué)習(xí)如何使用Spire.PDF for .NET以編程方式創(chuàng)建 PDF 作品集。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
PDF 作品集是一組文件,其中可以包含文本文檔、電子表格、電子郵件、圖像、PowerPoint 演示文稿和繪圖。盡管 PDF 作品集將不同類型的文件組合成一個(gè)單元,但其中的每個(gè)文件都保留了其原始格式、分辨率和大小。在本文中,您將學(xué)習(xí)如何使用Spire.PDF for .NET以編程方式創(chuàng)建 PDF 作品集。
Spire.PDF for .NET 是一款獨(dú)立 PDF 控件,用于 .NET 程序中創(chuàng)建、編輯和操作 PDF 文檔。使用 Spire.PDF 類庫,開發(fā)人員可以新建一個(gè) PDF 文檔或者對現(xiàn)有的 PDF 文檔進(jìn)行處理,且無需安裝 Adobe Acrobat。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團(tuán)隊(duì)研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時(shí)適配國產(chǎn)操作系統(tǒng)如中科方德、中標(biāo)麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
由于 PDF 文件包是文件的集合,Spire.PDF for .NET 允許您使用PdfDocument.Collection屬性輕松創(chuàng)建它。然后,您可以使用PdfCollection.AddFile()方法將文件添加到 PDF 文件包中。詳細(xì)步驟如下:
【C#】
using System;
using Spire.Pdf;
namespace CreatePDFPortfolio
{
class Program
{
static void Main(string[] args)
{
// Specify the files
String[] files = new String[] { "input.pdf", "sample.docx", "report.xlsx", "Intro.pptx", "logo.png" };
//Create a PdfDocument instance
using (PdfDocument pdf = new PdfDocument())
{
//Create a PDF portfolio and add files to it
for (int i = 0; i < files.Length; i++)
{
pdf.Collection.AddFile(files[i]);
}
//Save the result file
pdf.SaveToFile("PortfolioWithFiles.pdf", FileFormat.PDF);
pdf.Dispose();
}
}
}
}
【VB.NET】
Imports Spire.Pdf
Namespace CreatePDFPortfolio
Class Program
Private Shared Sub Main(ByVal args() As String)
' Specify the files
Dim files() As String = New String() {"input.pdf", "sample.docx", "report.xlsx", "Intro.pptx", "logo.png"}
'Create a PdfDocument instance
Dim pdf As PdfDocument = New PdfDocument
'Create a PDF portfolio and add files to it
Dim i As Integer = 0
Do While (i < files.Length)
pdf.Collection.AddFile(files(i))
i = (i + 1)
Loop
'Save the result file
pdf.SaveToFile("PortfolioWithFiles.pdf", FileFormat.PDF)
pdf.Dispose()
End Sub
End Class
End Namespace
創(chuàng)建 PDF 文件包后,Spire.PDF for .NET 還允許您在 PDF 文件包內(nèi)創(chuàng)建文件夾以進(jìn)一步管理文件。詳細(xì)步驟如下:
【C#】
using System;
using Spire.Pdf;
using Spire.Pdf.Collections;
namespace CreatePDFPortfolio
{
class Program
{
static void Main(string[] args)
{
// Specify the files
String[] files = new String[] { "input.pdf", "sample.docx", "report.xlsx", "Intro.pptx", "logo.png" };
//Create a PdfDocument instance
using (PdfDocument pdf = new PdfDocument())
{
//Create a PDF portfolio and add folders to it
for (int i = 0; i < files.Length; i++)
{
PdfFolder folder = pdf.Collection.Folders.CreateSubfolder("Folder" + i);
//Add files to the folders
folder.AddFile(files[i]);
}
//Save the result file
pdf.SaveToFile("PortfolioWithFolders.pdf", FileFormat.PDF);
pdf.Dispose();
}
}
}
}
【VB.NET
Imports Spire.Pdf
Imports Spire.Pdf.Collections
Namespace CreatePDFPortfolio
Class Program
Private Shared Sub Main(ByVal args() As String)
' Specify the files
Dim files() As String = New String() {"input.pdf", "sample.docx", "report.xlsx", "Intro.pptx", "logo.png"}
'Create a PdfDocument instance
Dim pdf As PdfDocument = New PdfDocument
'Create a PDF portfolio and add folders to it
Dim i As Integer = 0
Do While (i < files.Length)
Dim folder As PdfFolder = pdf.Collection.Folders.CreateSubfolder(("Folder" + i))
'Add files to the folders
folder.AddFile(files(i))
i = (i + 1)
Loop
'Save the result file
pdf.SaveToFile("PortfolioWithFolders.pdf", FileFormat.PDF)
pdf.Dispose()
End Sub
End Class
End Namespace

歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn