添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
使用.NET、.NET Core、Java、C++ 和安卓系统合并 PDF 文件的原生 API。 合并一个或多个 PDF 文档是一项非常受欢迎的任务。Aspose.PDF 库在使用它方面做得非常出色。该示例是用 C# 编写的,但该 API 可以在其他 .NET 编程语言(如 VB.NET)中使用。合并PDF文件的方式是将第一个文件合并到另一个文档的末尾。Aspose.PDF 显示了组合各种格式的文件。点击链接,熟悉将文件与 Aspose.PDF 库合并的所有可能性。 可能要合并PDF文件的原因有很多。例如,合并 PDF 文件允许您打印单个文件,而不必将多个文档排队打印,而合并相关文件可减少需要搜索和整理的文件数量,从而简化了管理和存储许多文档的过程。
// Open first document
Document pdfDocument1 = new Document(_dataDir + "Concat1.pdf");
// Open second document
Document pdfDocument2 = new Document(_dataDir + "Concat2.pdf");
// Add pages of second document to the first
document1.Pages.Add(document2.Pages);
document.Save(_dataDir+"ConcatenatedPDF.pdf");
// Create PdfFileEditor object
PdfFileEditor fileEditor = new PdfFileEditor();
String[] files = new String[] { "file1.pdf", "file2.pdf", "pdf3.pdf" };
// Merge multiple PDF files
fileEditor.concatenate(files, "merged-pdf.pdf");
auto doc2 = MakeObject<Document>(u"file2.pdf");
// Add pages of second document to the first
doc1->get_Pages()->Add(doc2->get_Pages());
// Save concatenated output file
doc1->Save(u"merged-output.pdf");

尝试通过 Python 合并 PDF 文件

在 Python 中合并 PDF 文件的示例代码。

通过 Python 将 PDF 与 Python 库中的 Aspose.PDF for .NET 结合起来。

Python example

import aspose.pdf as ap
# Open first document
document1 = ap.Document(input_pdf_1)
# Open second document
document2 = ap.Document(input_pdf_2)
# Add pages of second document to the first
document1.pages.add(document2.pages)
# Save concatenated output file
document1.save(output_pdf)