// PM> Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;
// Instantiate Renderer
var Renderer = new IronPdf.ChromePdfRenderer();
// Join Multiple Existing PDFs into a single document
var PDFs = new List<PdfDocument>();
PDFs.Add(PdfDocument.FromFile("A.pdf"));
PDFs.Add(PdfDocument.FromFile("B.pdf"));
PDFs.Add(PdfDocument.FromFile("C.pdf"));
using PdfDocument PDF = PdfDocument.Merge(PDFs);
PDF.SaveAs("merged.pdf");
// Add a cover page
PDF.PrependPdf(Renderer.RenderHtmlAsPdf("<h1>Cover Page</h1><hr>"));
// Remove the last page from the PDF and save again
PDF.RemovePage(PDF.PageCount - 1);
PDF.SaveAs("merged.pdf");
// Copy pages 5-7 and save them as a new document.
PDF.CopyPages(4, 6).SaveAs("exerpt.pdf");
foreach (var pdf in PDFs)
{
pdf.Dispose();
}
' PM> Install-Package IronPdf
Imports IronPdf
Imports System.Collections.Generic
' Instantiate Renderer
Private Renderer = New IronPdf.ChromePdfRenderer()
' Join Multiple Existing PDFs into a single document
Private PDFs = New List(Of PdfDocument)()
PDFs.Add(PdfDocument.FromFile("A.pdf"))
PDFs.Add(PdfDocument.FromFile("B.pdf"))
PDFs.Add(PdfDocument.FromFile("C.pdf"))
Using PDF As PdfDocument = PdfDocument.Merge(PDFs)
PDF.SaveAs("merged.pdf")
' Add a cover page
PDF.PrependPdf(Renderer.RenderHtmlAsPdf("<h1>Cover Page</h1><hr>"))
' Remove the last page from the PDF and save again
PDF.RemovePage(PDF.PageCount - 1)
PDF.SaveAs("merged.pdf")
' Copy pages 5-7 and save them as a new document.
PDF.CopyPages(4, 6).SaveAs("exerpt.pdf")
'INSTANT VB NOTE: The variable pdf was renamed since Visual Basic will not allow local variables with the same name as parameters or other local variables:
For Each Me.pdf_Conflict In PDFs
Me.pdf_Conflict.Dispose()
Next pdf_Conflict
End Using