移除特定 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
PdfDocumentobject.RemovePage(0): This method is called on the
PdfDocumentobject to remove the first page of the PDF. Page numbering starts with 0, so0represents the first page.SaveAs(outputPath): Any changes made to the
PdfDocumentobject are saved to a new file specified byoutputPath.- Console.WriteLine :向控制台列印完成訊息,指示修改後的 PDF 的位置。
Keep in mind to replace "input.pdf" and "output.pdf" with your actual file paths.




