移除特定 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 頁面

準備好開始了嗎?
版本: 2026.3 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想要快速證明?
執行範例 觀看您的 HTML 變成 PDF。