删除特定PDF页面
要从 PDF 文档中删除单个或多个页面,请使用 removePage 方法。 编辑后的 PDF 文档可以使用 IronPDF 的 saveAs 方法导出,IronPDF 是一个强大的 .NET PDF 库,允许您以编程方式创建、编辑和操作 PDF 文件。 您可以在 IronPDF 官方网站上了解更多关于 IronPDF 功能的信息。
- PdfWriter:此对象负责写入PDF文件。它作用于文件路径,并写入有效PDF文档所需的结构。
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.




