移除特定的 PDF 頁面

若要從 PDF 文件中刪除單一或多個頁面,請使用removePage方法。 然後可以使用 IronPDF 的saveAs方法匯出編輯後的 PDF 文件。 IronPDF 是一個功能強大的 .NET PDF 程式庫,可讓您以程式設計方式建立、編輯和操作 PDF 檔案。 您可以在IronPDF 官方網站上了解更多關於 IronPDF 的功能資訊。

說明:

  • IronPdf :該程式碼使用了 IronPdf,這是一個用於 PDF 處理的 .NET 程式庫。 請確保您的專案中已安裝此程式庫。

  • PdfDocument.FromFile(inputPath): This loads the PDF from the given file path into a PdfDocument object.

  • RemovePage(0): This method is called on the PdfDocument object to remove the first page of the PDF. Page numbering starts with 0, so 0 represents the first page.

  • SaveAs(outputPath): Any changes made to the PdfDocument object are saved to a new file specified by outputPath.

  • Console.WriteLine :向控制台列印完成訊息,指示修改後的 PDF 的位置。

Keep in mind to replace "input.pdf" and "output.pdf" with your actual file paths.

瀏覽 GitHub 上的範例,了解如何使用 IronPDF 刪除 PDF 頁面

準備好開始了嗎?
版本: 2025.12 剛發表