using IronPdf;using System.Collections.Generic;// Copy a single page into a new PDF objectPdfDocument myReport = PdfDocument.FromFile("report_final.pdf");PdfDocument copyOfPageOne = myReport.CopyPage(0);// Copy multiple pages into a new PDF objectPdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
using IronPdf;
using System.Collections.Generic;
// Copy a single page into a new PDF object
PdfDocument myReport = PdfDocument.FromFile("report_final.pdf");
PdfDocument copyOfPageOne = myReport.CopyPage(0);
// Copy multiple pages into a new PDF object
PdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
ImportsIronPdfImportsSystem.Collections.Generic' Copy a single page into a new PDF objectPrivate myReport AsPdfDocument = PdfDocument.FromFile("report_final.pdf")Private copyOfPageOne AsPdfDocument = myReport.CopyPage(0)' Copy multiple pages into a new PDF objectPrivate copyOfFirstThreePages AsPdfDocument = myReport.CopyPages(New List(OfInteger) From {0, 1, 2})
Imports IronPdf
Imports System.Collections.Generic
' Copy a single page into a new PDF object
Private myReport As PdfDocument = PdfDocument.FromFile("report_final.pdf")
Private copyOfPageOne As PdfDocument = myReport.CopyPage(0)
' Copy multiple pages into a new PDF object
Private copyOfFirstThreePages As PdfDocument = myReport.CopyPages(New List(Of Integer) From {0, 1, 2})
using IronPdf;using System.Collections.Generic;PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");// Remove a single pagepdf.RemovePage(0);// Remove multiple pagespdf.RemovePages(new List<int> { 2, 3 });
using IronPdf;
using System.Collections.Generic;
PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");
// Remove a single page
pdf.RemovePage(0);
// Remove multiple pages
pdf.RemovePages(new List<int> { 2, 3 });
ImportsIronPdfImportsSystem.Collections.GenericPrivate pdf AsPdfDocument = PdfDocument.FromFile("full_report.pdf")' Remove a single pagepdf.RemovePage(0)' Remove multiple pagespdf.RemovePages(New List(OfInteger) From {2, 3})
Imports IronPdf
Imports System.Collections.Generic
Private pdf As PdfDocument = PdfDocument.FromFile("full_report.pdf")
' Remove a single page
pdf.RemovePage(0)
' Remove multiple pages
pdf.RemovePages(New List(Of Integer) From {2, 3})
using IronPdf;// We will use the 4-page PDF from the Merge example above:var pdf = PdfDocument.FromFile("Merged.pdf");// Takes only the first page into a new PDFvar page1doc = pdf.CopyPage(0);page1doc.SaveAs("Page1Only.pdf");// Take the pages 2 & 3 (Note: index starts at 0)var page23doc = pdf.CopyPages(1, 2);page23doc.SaveAs("Pages2to3.pdf");
using IronPdf;
// We will use the 4-page PDF from the Merge example above:
var pdf = PdfDocument.FromFile("Merged.pdf");
// Takes only the first page into a new PDF
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Page1Only.pdf");
// Take the pages 2 & 3 (Note: index starts at 0)
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Pages2to3.pdf");
ImportsIronPdf' We will use the 4-page PDF from the Merge example above:Private pdf = PdfDocument.FromFile("Merged.pdf")' Takes only the first page into a new PDFPrivate page1doc = pdf.CopyPage(0)page1doc.SaveAs("Page1Only.pdf")' Take the pages 2 & 3 (Note: index starts at 0)Dim page23doc = pdf.CopyPages(1, 2)page23doc.SaveAs("Pages2to3.pdf")
Imports IronPdf
' We will use the 4-page PDF from the Merge example above:
Private pdf = PdfDocument.FromFile("Merged.pdf")
' Takes only the first page into a new PDF
Private page1doc = pdf.CopyPage(0)
page1doc.SaveAs("Page1Only.pdf")
' Take the pages 2 & 3 (Note: index starts at 0)
Dim page23doc = pdf.CopyPages(1, 2)
page23doc.SaveAs("Pages2to3.pdf")
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");for (int idx = 0; idx < pdf.PageCount; idx++){ // Create new document for each page PdfDocument outputDocument = pdf.CopyPage(idx); string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf"; // Export to new file outputDocument.SaveAs(fileName);}
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");
for (int idx = 0; idx < pdf.PageCount; idx++)
{
// Create new document for each page
PdfDocument outputDocument = pdf.CopyPage(idx);
string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf";
// Export to new file
outputDocument.SaveAs(fileName);
}
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("multiPage.pdf")For idx AsInteger = 0 To pdf.PageCount - 1 ' Create new document for each page Dim outputDocument AsPdfDocument = pdf.CopyPage(idx) Dim fileName AsString = $"multiPage - Page {idx + 1}_tempfile.pdf" ' Export to new file outputDocument.SaveAs(fileName)Next idx
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("multiPage.pdf")
For idx As Integer = 0 To pdf.PageCount - 1
' Create new document for each page
Dim outputDocument As PdfDocument = pdf.CopyPage(idx)
Dim fileName As String = $"multiPage - Page {idx + 1}_tempfile.pdf"
' Export to new file
outputDocument.SaveAs(fileName)
Next idx
using IronPdf;using System.IO;// Import attachment filebyte[] fileData = File.ReadAllBytes(@"path/to/file");// Open existing PDFPdfDocument pdf = PdfDocument.FromFile("sample.pdf");// Add attachment to the PDFpdf.Attachments.AddAttachment("Example", fileData);pdf.SaveAs("addAttachment.pdf");
using IronPdf;
using System.IO;
// Import attachment file
byte[] fileData = File.ReadAllBytes(@"path/to/file");
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData);
pdf.SaveAs("addAttachment.pdf");
ImportsIronPdfImportsSystem.IO' Import attachment filePrivate fileData() AsByte = File.ReadAllBytes("path/to/file")' Open existing PDFPrivate pdf AsPdfDocument = PdfDocument.FromFile("sample.pdf")' Add attachment to the PDFpdf.Attachments.AddAttachment("Example", fileData)pdf.SaveAs("addAttachment.pdf")
Imports IronPdf
Imports System.IO
' Import attachment file
Private fileData() As Byte = File.ReadAllBytes("path/to/file")
' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData)
pdf.SaveAs("addAttachment.pdf")
添付ファイルを削除
using IronPdf;using System.Linq;// Open existing PDFPdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");// Add attachment to the PDFPdfAttachmentCollection retrieveAttachments = pdf.Attachments;// Remove attachment from PDFpdf.Attachments.RemoveAttachment(retrieveAttachments.First());pdf.SaveAs("removeAttachment.pdf");
using IronPdf;
using System.Linq;
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");
// Add attachment to the PDF
PdfAttachmentCollection retrieveAttachments = pdf.Attachments;
// Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First());
pdf.SaveAs("removeAttachment.pdf");
ImportsIronPdfImportsSystem.Linq' Open existing PDFPrivate pdf AsPdfDocument = PdfDocument.FromFile("addAttachment.pdf")' Add attachment to the PDFPrivate retrieveAttachments AsPdfAttachmentCollection = pdf.Attachments' Remove attachment from PDFpdf.Attachments.RemoveAttachment(retrieveAttachments.First())pdf.SaveAs("removeAttachment.pdf")
Imports IronPdf
Imports System.Linq
' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("addAttachment.pdf")
' Add attachment to the PDF
Private retrieveAttachments As PdfAttachmentCollection = pdf.Attachments
' Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First())
pdf.SaveAs("removeAttachment.pdf")
using IronPdf;// Create a new PDF or edit an existing document.PdfDocument pdf = PdfDocument.FromFile("existing.pdf");// Add a bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);// Add a sub-bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);pdf.SaveAs("singleLayerBookmarks.pdf");
using IronPdf;
// Create a new PDF or edit an existing document.
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");
// Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);
// Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);
pdf.SaveAs("singleLayerBookmarks.pdf");
ImportsIronPdf' Create a new PDF or edit an existing document.Private pdf AsPdfDocument = PdfDocument.FromFile("existing.pdf")' Add a bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0)' Add a sub-bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1)pdf.SaveAs("singleLayerBookmarks.pdf")
Imports IronPdf
' Create a new PDF or edit an existing document.
Private pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")
' Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0)
' Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1)
pdf.SaveAs("singleLayerBookmarks.pdf")
using IronPdf;// Load existing PDF documentPdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");// Retrieve bookmarks listvar mainBookmark = pdf.Bookmarks.GetAllBookmarks();
using IronPdf;
// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");
// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();
ImportsIronPdf' Load existing PDF documentPrivate pdf AsPdfDocument = PdfDocument.FromFile("multiLayerBookmarks.pdf")' Retrieve bookmarks listPrivate mainBookmark = pdf.Bookmarks.GetAllBookmarks()
Imports IronPdf
' Load existing PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("multiLayerBookmarks.pdf")
' Retrieve bookmarks list
Private mainBookmark = pdf.Bookmarks.GetAllBookmarks()